OLD | NEW |
---|---|
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 174 |
175 CHECK(!env->InContext()); | 175 CHECK(!env->InContext()); |
176 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 176 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); |
177 env->Enter(); | 177 env->Enter(); |
178 CHECK(env->InContext()); | 178 CHECK(env->InContext()); |
179 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 179 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); |
180 env->Exit(); | 180 env->Exit(); |
181 CHECK(!env->InContext()); | 181 CHECK(!env->InContext()); |
182 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 182 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); |
183 | 183 |
184 env.Dispose(); | 184 env.Dispose(env->GetIsolate()); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 THREADED_TEST(ReceiverSignature) { | 188 THREADED_TEST(ReceiverSignature) { |
189 v8::HandleScope scope; | 189 v8::HandleScope scope; |
190 LocalContext env; | 190 LocalContext env; |
191 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 191 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); |
192 v8::Handle<v8::Signature> sig = v8::Signature::New(fun); | 192 v8::Handle<v8::Signature> sig = v8::Signature::New(fun); |
193 fun->PrototypeTemplate()->Set( | 193 fun->PrototypeTemplate()->Set( |
194 v8_str("m"), | 194 v8_str("m"), |
(...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2317 | 2317 |
2318 | 2318 |
2319 THREADED_TEST(GlobalHandle) { | 2319 THREADED_TEST(GlobalHandle) { |
2320 v8::Persistent<String> global; | 2320 v8::Persistent<String> global; |
2321 { | 2321 { |
2322 v8::HandleScope scope; | 2322 v8::HandleScope scope; |
2323 Local<String> str = v8_str("str"); | 2323 Local<String> str = v8_str("str"); |
2324 global = v8::Persistent<String>::New(str); | 2324 global = v8::Persistent<String>::New(str); |
2325 } | 2325 } |
2326 CHECK_EQ(global->Length(), 3); | 2326 CHECK_EQ(global->Length(), 3); |
2327 global.Dispose(); | 2327 global.Dispose(v8::Isolate::GetCurrent()); |
2328 | 2328 |
2329 { | 2329 { |
2330 v8::HandleScope scope; | 2330 v8::HandleScope scope; |
2331 Local<String> str = v8_str("str"); | 2331 Local<String> str = v8_str("str"); |
2332 global = v8::Persistent<String>::New(str); | 2332 global = v8::Persistent<String>::New(str); |
2333 } | 2333 } |
2334 CHECK_EQ(global->Length(), 3); | 2334 CHECK_EQ(global->Length(), 3); |
2335 global.Dispose(v8::Isolate::GetCurrent()); | 2335 global.Dispose(v8::Isolate::GetCurrent()); |
2336 } | 2336 } |
2337 | 2337 |
(...skipping 13 matching lines...) Expand all Loading... | |
2351 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } | 2351 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } |
2352 int id() { return id_; } | 2352 int id() { return id_; } |
2353 void increment() { number_of_weak_calls_++; } | 2353 void increment() { number_of_weak_calls_++; } |
2354 int NumberOfWeakCalls() { return number_of_weak_calls_; } | 2354 int NumberOfWeakCalls() { return number_of_weak_calls_; } |
2355 private: | 2355 private: |
2356 int id_; | 2356 int id_; |
2357 int number_of_weak_calls_; | 2357 int number_of_weak_calls_; |
2358 }; | 2358 }; |
2359 | 2359 |
2360 | 2360 |
2361 static void WeakPointerCallback(Persistent<Value> handle, void* id) { | 2361 static void WeakPointerCallback(v8::Isolate* isolate, |
2362 Persistent<Value> handle, | |
2363 void* id) { | |
2362 WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id); | 2364 WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id); |
2363 CHECK_EQ(1234, counter->id()); | 2365 CHECK_EQ(1234, counter->id()); |
2364 counter->increment(); | 2366 counter->increment(); |
2365 handle.Dispose(); | 2367 handle.Dispose(isolate); |
2366 } | 2368 } |
2367 | 2369 |
2368 | 2370 |
2369 THREADED_TEST(ApiObjectGroups) { | 2371 THREADED_TEST(ApiObjectGroups) { |
2370 HandleScope scope; | 2372 HandleScope scope; |
2371 LocalContext env; | 2373 LocalContext env; |
2374 v8::Isolate* iso = env->GetIsolate(); | |
2372 | 2375 |
2373 Persistent<Object> g1s1; | 2376 Persistent<Object> g1s1; |
2374 Persistent<Object> g1s2; | 2377 Persistent<Object> g1s2; |
2375 Persistent<Object> g1c1; | 2378 Persistent<Object> g1c1; |
2376 Persistent<Object> g2s1; | 2379 Persistent<Object> g2s1; |
2377 Persistent<Object> g2s2; | 2380 Persistent<Object> g2s2; |
2378 Persistent<Object> g2c1; | 2381 Persistent<Object> g2c1; |
2379 | 2382 |
2380 WeakCallCounter counter(1234); | 2383 WeakCallCounter counter(1234); |
2381 | 2384 |
2382 { | 2385 { |
2383 HandleScope scope; | 2386 HandleScope scope; |
2384 g1s1 = Persistent<Object>::New(Object::New()); | 2387 g1s1 = Persistent<Object>::New(Object::New()); |
2385 g1s2 = Persistent<Object>::New(Object::New()); | 2388 g1s2 = Persistent<Object>::New(Object::New()); |
2386 g1c1 = Persistent<Object>::New(Object::New()); | 2389 g1c1 = Persistent<Object>::New(Object::New()); |
2387 g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2390 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2388 g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2391 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2389 g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2392 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2390 | 2393 |
2391 g2s1 = Persistent<Object>::New(Object::New()); | 2394 g2s1 = Persistent<Object>::New(Object::New()); |
2392 g2s2 = Persistent<Object>::New(Object::New()); | 2395 g2s2 = Persistent<Object>::New(Object::New()); |
2393 g2c1 = Persistent<Object>::New(Object::New()); | 2396 g2c1 = Persistent<Object>::New(Object::New()); |
2394 g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2397 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2395 g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2398 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2396 g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2399 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2397 } | 2400 } |
2398 | 2401 |
2399 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. | 2402 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. |
2400 | 2403 |
2401 // Connect group 1 and 2, make a cycle. | 2404 // Connect group 1 and 2, make a cycle. |
2402 CHECK(g1s2->Set(0, g2s2)); | 2405 CHECK(g1s2->Set(0, g2s2)); |
2403 CHECK(g2s1->Set(0, g1s1)); | 2406 CHECK(g2s1->Set(0, g1s1)); |
2404 | 2407 |
2405 { | 2408 { |
2406 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; | 2409 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
2407 Persistent<Value> g1_children[] = { g1c1 }; | 2410 Persistent<Value> g1_children[] = { g1c1 }; |
2408 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; | 2411 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
2409 Persistent<Value> g2_children[] = { g2c1 }; | 2412 Persistent<Value> g2_children[] = { g2c1 }; |
2410 V8::AddObjectGroup(g1_objects, 2); | 2413 V8::AddObjectGroup(g1_objects, 2); |
2411 V8::AddImplicitReferences(g1s1, g1_children, 1); | 2414 V8::AddImplicitReferences(g1s1, g1_children, 1); |
2412 V8::AddObjectGroup(g2_objects, 2); | 2415 V8::AddObjectGroup(g2_objects, 2); |
2413 V8::AddImplicitReferences(g2s2, g2_children, 1); | 2416 V8::AddImplicitReferences(g2s2, g2_children, 1); |
2414 } | 2417 } |
2415 // Do a single full GC, ensure incremental marking is stopped. | 2418 // Do a single full GC, ensure incremental marking is stopped. |
2416 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2419 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
2417 | 2420 |
2418 // All object should be alive. | 2421 // All object should be alive. |
2419 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 2422 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
2420 | 2423 |
2421 // Weaken the root. | 2424 // Weaken the root. |
2422 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2425 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2423 // But make children strong roots---all the objects (except for children) | 2426 // But make children strong roots---all the objects (except for children) |
2424 // should be collectable now. | 2427 // should be collectable now. |
2425 g1c1.ClearWeak(); | 2428 g1c1.ClearWeak(iso); |
2426 g2c1.ClearWeak(); | 2429 g2c1.ClearWeak(iso); |
2427 | 2430 |
2428 // Groups are deleted, rebuild groups. | 2431 // Groups are deleted, rebuild groups. |
2429 { | 2432 { |
2430 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; | 2433 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
2431 Persistent<Value> g1_children[] = { g1c1 }; | 2434 Persistent<Value> g1_children[] = { g1c1 }; |
2432 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; | 2435 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
2433 Persistent<Value> g2_children[] = { g2c1 }; | 2436 Persistent<Value> g2_children[] = { g2c1 }; |
2434 V8::AddObjectGroup(g1_objects, 2); | 2437 V8::AddObjectGroup(g1_objects, 2); |
2435 V8::AddImplicitReferences(g1s1, g1_children, 1); | 2438 V8::AddImplicitReferences(g1s1, g1_children, 1); |
2436 V8::AddObjectGroup(g2_objects, 2); | 2439 V8::AddObjectGroup(g2_objects, 2); |
2437 V8::AddImplicitReferences(g2s2, g2_children, 1); | 2440 V8::AddImplicitReferences(g2s2, g2_children, 1); |
2438 } | 2441 } |
2439 | 2442 |
2440 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2443 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
2441 | 2444 |
2442 // All objects should be gone. 5 global handles in total. | 2445 // All objects should be gone. 5 global handles in total. |
2443 CHECK_EQ(5, counter.NumberOfWeakCalls()); | 2446 CHECK_EQ(5, counter.NumberOfWeakCalls()); |
2444 | 2447 |
2445 // And now make children weak again and collect them. | 2448 // And now make children weak again and collect them. |
2446 g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2449 g1c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2447 g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2450 g2c1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2448 | 2451 |
2449 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2452 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
2450 CHECK_EQ(7, counter.NumberOfWeakCalls()); | 2453 CHECK_EQ(7, counter.NumberOfWeakCalls()); |
2451 } | 2454 } |
2452 | 2455 |
2453 | 2456 |
2454 THREADED_TEST(ApiObjectGroupsCycle) { | 2457 THREADED_TEST(ApiObjectGroupsCycle) { |
2455 HandleScope scope; | 2458 HandleScope scope; |
2456 LocalContext env; | 2459 LocalContext env; |
2460 v8::Isolate* iso = env->GetIsolate(); | |
2457 | 2461 |
2458 WeakCallCounter counter(1234); | 2462 WeakCallCounter counter(1234); |
2459 | 2463 |
2460 Persistent<Object> g1s1; | 2464 Persistent<Object> g1s1; |
2461 Persistent<Object> g1s2; | 2465 Persistent<Object> g1s2; |
2462 Persistent<Object> g2s1; | 2466 Persistent<Object> g2s1; |
2463 Persistent<Object> g2s2; | 2467 Persistent<Object> g2s2; |
2464 Persistent<Object> g3s1; | 2468 Persistent<Object> g3s1; |
2465 Persistent<Object> g3s2; | 2469 Persistent<Object> g3s2; |
2466 Persistent<Object> g4s1; | 2470 Persistent<Object> g4s1; |
2467 Persistent<Object> g4s2; | 2471 Persistent<Object> g4s2; |
2468 | 2472 |
2469 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
2470 { | 2473 { |
2471 HandleScope scope; | 2474 HandleScope scope; |
2472 g1s1 = Persistent<Object>::New(Object::New()); | 2475 g1s1 = Persistent<Object>::New(Object::New()); |
2473 g1s2 = Persistent<Object>::New(Object::New()); | 2476 g1s2 = Persistent<Object>::New(Object::New()); |
2474 g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2477 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2475 g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2478 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2476 CHECK(g1s1.IsWeak()); | 2479 CHECK(g1s1.IsWeak(iso)); |
2477 CHECK(g1s2.IsWeak()); | 2480 CHECK(g1s2.IsWeak(iso)); |
2478 | 2481 |
2479 g2s1 = Persistent<Object>::New(Object::New()); | 2482 g2s1 = Persistent<Object>::New(Object::New()); |
2480 g2s2 = Persistent<Object>::New(Object::New()); | 2483 g2s2 = Persistent<Object>::New(Object::New()); |
2481 g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2484 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2482 g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2485 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2483 CHECK(g2s1.IsWeak()); | 2486 CHECK(g2s1.IsWeak(iso)); |
2484 CHECK(g2s2.IsWeak()); | 2487 CHECK(g2s2.IsWeak(iso)); |
2485 | 2488 |
2486 g3s1 = Persistent<Object>::New(Object::New()); | 2489 g3s1 = Persistent<Object>::New(Object::New()); |
2487 g3s2 = Persistent<Object>::New(Object::New()); | 2490 g3s2 = Persistent<Object>::New(Object::New()); |
2488 g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2491 g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2489 g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2492 g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2490 CHECK(g3s1.IsWeak()); | 2493 CHECK(g3s1.IsWeak(iso)); |
2491 CHECK(g3s2.IsWeak()); | 2494 CHECK(g3s2.IsWeak(iso)); |
2492 | 2495 |
2493 g4s1 = Persistent<Object>::New(Object::New()); | 2496 g4s1 = Persistent<Object>::New(Object::New()); |
2494 g4s2 = Persistent<Object>::New(Object::New()); | 2497 g4s2 = Persistent<Object>::New(Object::New()); |
2495 g4s1.MakeWeak(isolate, | 2498 g4s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2496 reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2499 g4s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2497 g4s2.MakeWeak(isolate, | 2500 CHECK(g4s1.IsWeak(iso)); |
2498 reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2501 CHECK(g4s2.IsWeak(iso)); |
2499 CHECK(g4s1.IsWeak(isolate)); | |
2500 CHECK(g4s2.IsWeak(isolate)); | |
2501 } | 2502 } |
2502 | 2503 |
2503 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. | 2504 Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. |
2504 | 2505 |
2505 // Connect groups. We're building the following cycle: | 2506 // Connect groups. We're building the following cycle: |
2506 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | 2507 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
2507 // groups. | 2508 // groups. |
2508 { | 2509 { |
2509 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; | 2510 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
2510 Persistent<Value> g1_children[] = { g2s1 }; | 2511 Persistent<Value> g1_children[] = { g2s1 }; |
2511 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; | 2512 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
2512 Persistent<Value> g2_children[] = { g3s1 }; | 2513 Persistent<Value> g2_children[] = { g3s1 }; |
2513 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; | 2514 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; |
2514 Persistent<Value> g3_children[] = { g4s1 }; | 2515 Persistent<Value> g3_children[] = { g4s1 }; |
2515 Persistent<Value> g4_objects[] = { g4s1, g4s2 }; | 2516 Persistent<Value> g4_objects[] = { g4s1, g4s2 }; |
2516 Persistent<Value> g4_children[] = { g1s1 }; | 2517 Persistent<Value> g4_children[] = { g1s1 }; |
2517 V8::AddObjectGroup(g1_objects, 2); | 2518 V8::AddObjectGroup(g1_objects, 2); |
2518 V8::AddImplicitReferences(g1s1, g1_children, 1); | 2519 V8::AddImplicitReferences(g1s1, g1_children, 1); |
2519 V8::AddObjectGroup(g2_objects, 2); | 2520 V8::AddObjectGroup(g2_objects, 2); |
2520 V8::AddImplicitReferences(g2s1, g2_children, 1); | 2521 V8::AddImplicitReferences(g2s1, g2_children, 1); |
2521 V8::AddObjectGroup(g3_objects, 2); | 2522 V8::AddObjectGroup(g3_objects, 2); |
2522 V8::AddImplicitReferences(g3s1, g3_children, 1); | 2523 V8::AddImplicitReferences(g3s1, g3_children, 1); |
2523 V8::AddObjectGroup(isolate, g4_objects, 2); | 2524 V8::AddObjectGroup(iso, g4_objects, 2); |
2524 V8::AddImplicitReferences(g4s1, g4_children, 1); | 2525 V8::AddImplicitReferences(g4s1, g4_children, 1); |
2525 } | 2526 } |
2526 // Do a single full GC | 2527 // Do a single full GC |
2527 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 2528 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
2528 | 2529 |
2529 // All object should be alive. | 2530 // All object should be alive. |
2530 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 2531 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
2531 | 2532 |
2532 // Weaken the root. | 2533 // Weaken the root. |
2533 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2534 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2534 | 2535 |
2535 // Groups are deleted, rebuild groups. | 2536 // Groups are deleted, rebuild groups. |
2536 { | 2537 { |
2537 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; | 2538 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
2538 Persistent<Value> g1_children[] = { g2s1 }; | 2539 Persistent<Value> g1_children[] = { g2s1 }; |
2539 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; | 2540 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
2540 Persistent<Value> g2_children[] = { g3s1 }; | 2541 Persistent<Value> g2_children[] = { g3s1 }; |
2541 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; | 2542 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; |
2542 Persistent<Value> g3_children[] = { g4s1 }; | 2543 Persistent<Value> g3_children[] = { g4s1 }; |
2543 Persistent<Value> g4_objects[] = { g4s1, g4s2 }; | 2544 Persistent<Value> g4_objects[] = { g4s1, g4s2 }; |
(...skipping 15 matching lines...) Expand all Loading... | |
2559 } | 2560 } |
2560 | 2561 |
2561 | 2562 |
2562 // TODO(mstarzinger): This should be a THREADED_TEST but causes failures | 2563 // TODO(mstarzinger): This should be a THREADED_TEST but causes failures |
2563 // on the buildbots, so was made non-threaded for the time being. | 2564 // on the buildbots, so was made non-threaded for the time being. |
2564 TEST(ApiObjectGroupsCycleForScavenger) { | 2565 TEST(ApiObjectGroupsCycleForScavenger) { |
2565 i::FLAG_stress_compaction = false; | 2566 i::FLAG_stress_compaction = false; |
2566 i::FLAG_gc_global = false; | 2567 i::FLAG_gc_global = false; |
2567 HandleScope scope; | 2568 HandleScope scope; |
2568 LocalContext env; | 2569 LocalContext env; |
2570 v8::Isolate* iso = env->GetIsolate(); | |
2569 | 2571 |
2570 WeakCallCounter counter(1234); | 2572 WeakCallCounter counter(1234); |
2571 | 2573 |
2572 Persistent<Object> g1s1; | 2574 Persistent<Object> g1s1; |
2573 Persistent<Object> g1s2; | 2575 Persistent<Object> g1s2; |
2574 Persistent<Object> g2s1; | 2576 Persistent<Object> g2s1; |
2575 Persistent<Object> g2s2; | 2577 Persistent<Object> g2s2; |
2576 Persistent<Object> g3s1; | 2578 Persistent<Object> g3s1; |
2577 Persistent<Object> g3s2; | 2579 Persistent<Object> g3s2; |
2578 | 2580 |
2579 { | 2581 { |
2580 HandleScope scope; | 2582 HandleScope scope; |
2581 g1s1 = Persistent<Object>::New(Object::New()); | 2583 g1s1 = Persistent<Object>::New(Object::New()); |
2582 g1s2 = Persistent<Object>::New(Object::New()); | 2584 g1s2 = Persistent<Object>::New(Object::New()); |
2583 g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2585 g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2584 g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2586 g1s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2585 | 2587 |
2586 g2s1 = Persistent<Object>::New(Object::New()); | 2588 g2s1 = Persistent<Object>::New(Object::New()); |
2587 g2s2 = Persistent<Object>::New(Object::New()); | 2589 g2s2 = Persistent<Object>::New(Object::New()); |
2588 g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2590 g2s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2589 g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2591 g2s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2590 | 2592 |
2591 g3s1 = Persistent<Object>::New(Object::New()); | 2593 g3s1 = Persistent<Object>::New(Object::New()); |
2592 g3s2 = Persistent<Object>::New(Object::New()); | 2594 g3s2 = Persistent<Object>::New(Object::New()); |
2593 g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2595 g3s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2594 g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2596 g3s2.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2595 } | 2597 } |
2596 | 2598 |
2597 // Make a root. | 2599 // Make a root. |
2598 Persistent<Object> root = Persistent<Object>::New(g1s1); | 2600 Persistent<Object> root = Persistent<Object>::New(g1s1); |
2599 root.MarkPartiallyDependent(); | 2601 root.MarkPartiallyDependent(iso); |
2600 | 2602 |
2601 // Connect groups. We're building the following cycle: | 2603 // Connect groups. We're building the following cycle: |
2602 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other | 2604 // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other |
2603 // groups. | 2605 // groups. |
2604 { | 2606 { |
2605 g1s1.MarkPartiallyDependent(); | 2607 g1s1.MarkPartiallyDependent(iso); |
2606 g1s2.MarkPartiallyDependent(); | 2608 g1s2.MarkPartiallyDependent(iso); |
2607 g2s1.MarkPartiallyDependent(); | 2609 g2s1.MarkPartiallyDependent(iso); |
2608 g2s2.MarkPartiallyDependent(); | 2610 g2s2.MarkPartiallyDependent(iso); |
2609 g3s1.MarkPartiallyDependent(); | 2611 g3s1.MarkPartiallyDependent(iso); |
2610 g3s2.MarkPartiallyDependent(); | 2612 g3s2.MarkPartiallyDependent(iso); |
2611 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; | 2613 Persistent<Value> g1_objects[] = { g1s1, g1s2 }; |
2612 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; | 2614 Persistent<Value> g2_objects[] = { g2s1, g2s2 }; |
2613 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; | 2615 Persistent<Value> g3_objects[] = { g3s1, g3s2 }; |
2614 V8::AddObjectGroup(g1_objects, 2); | 2616 V8::AddObjectGroup(g1_objects, 2); |
2615 g1s1->Set(v8_str("x"), g2s1); | 2617 g1s1->Set(v8_str("x"), g2s1); |
2616 V8::AddObjectGroup(g2_objects, 2); | 2618 V8::AddObjectGroup(g2_objects, 2); |
2617 g2s1->Set(v8_str("x"), g3s1); | 2619 g2s1->Set(v8_str("x"), g3s1); |
2618 V8::AddObjectGroup(g3_objects, 2); | 2620 V8::AddObjectGroup(g3_objects, 2); |
2619 g3s1->Set(v8_str("x"), g1s1); | 2621 g3s1->Set(v8_str("x"), g1s1); |
2620 } | 2622 } |
2621 | 2623 |
2622 HEAP->CollectGarbage(i::NEW_SPACE); | 2624 HEAP->CollectGarbage(i::NEW_SPACE); |
2623 | 2625 |
2624 // All objects should be alive. | 2626 // All objects should be alive. |
2625 CHECK_EQ(0, counter.NumberOfWeakCalls()); | 2627 CHECK_EQ(0, counter.NumberOfWeakCalls()); |
2626 | 2628 |
2627 // Weaken the root. | 2629 // Weaken the root. |
2628 root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); | 2630 root.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback); |
2629 root.MarkPartiallyDependent(); | 2631 root.MarkPartiallyDependent(iso); |
2630 | 2632 |
2631 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 2633 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
2632 // Groups are deleted, rebuild groups. | 2634 // Groups are deleted, rebuild groups. |
2633 { | 2635 { |
2634 g1s1.MarkPartiallyDependent(isolate); | 2636 g1s1.MarkPartiallyDependent(isolate); |
2635 g1s2.MarkPartiallyDependent(isolate); | 2637 g1s2.MarkPartiallyDependent(isolate); |
2636 g2s1.MarkPartiallyDependent(isolate); | 2638 g2s1.MarkPartiallyDependent(isolate); |
2637 g2s2.MarkPartiallyDependent(isolate); | 2639 g2s2.MarkPartiallyDependent(isolate); |
2638 g3s1.MarkPartiallyDependent(isolate); | 2640 g3s1.MarkPartiallyDependent(isolate); |
2639 g3s2.MarkPartiallyDependent(isolate); | 2641 g3s2.MarkPartiallyDependent(isolate); |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3777 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); | 3779 CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
3778 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); | 3780 CHECK(v8_num(0)->StrictEquals(v8_num(-0))); |
3779 Local<Value> not_a_number = v8_num(i::OS::nan_value()); | 3781 Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
3780 CHECK(!not_a_number->StrictEquals(not_a_number)); | 3782 CHECK(!not_a_number->StrictEquals(not_a_number)); |
3781 CHECK(v8::False()->StrictEquals(v8::False())); | 3783 CHECK(v8::False()->StrictEquals(v8::False())); |
3782 CHECK(!v8::False()->StrictEquals(v8::Undefined())); | 3784 CHECK(!v8::False()->StrictEquals(v8::Undefined())); |
3783 | 3785 |
3784 v8::Handle<v8::Object> obj = v8::Object::New(); | 3786 v8::Handle<v8::Object> obj = v8::Object::New(); |
3785 v8::Persistent<v8::Object> alias = v8::Persistent<v8::Object>::New(obj); | 3787 v8::Persistent<v8::Object> alias = v8::Persistent<v8::Object>::New(obj); |
3786 CHECK(alias->StrictEquals(obj)); | 3788 CHECK(alias->StrictEquals(obj)); |
3787 alias.Dispose(); | 3789 alias.Dispose(context->GetIsolate()); |
3788 } | 3790 } |
3789 | 3791 |
3790 | 3792 |
3791 THREADED_TEST(MultiRun) { | 3793 THREADED_TEST(MultiRun) { |
3792 v8::HandleScope scope; | 3794 v8::HandleScope scope; |
3793 LocalContext context; | 3795 LocalContext context; |
3794 Local<Script> script = Script::Compile(v8_str("x")); | 3796 Local<Script> script = Script::Compile(v8_str("x")); |
3795 for (int i = 0; i < 10; i++) | 3797 for (int i = 0; i < 10; i++) |
3796 script->Run(); | 3798 script->Run(); |
3797 } | 3799 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4090 v8::HandleScope scope; | 4092 v8::HandleScope scope; |
4091 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4093 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4092 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); | 4094 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
4093 LocalContext context; | 4095 LocalContext context; |
4094 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4096 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4095 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); | 4097 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); |
4096 for (int i = 0; i < 10; i++) { | 4098 for (int i = 0; i < 10; i++) { |
4097 CHECK(xValue.IsEmpty()); | 4099 CHECK(xValue.IsEmpty()); |
4098 script->Run(); | 4100 script->Run(); |
4099 CHECK_EQ(v8_num(4), xValue); | 4101 CHECK_EQ(v8_num(4), xValue); |
4100 xValue.Dispose(); | 4102 xValue.Dispose(context->GetIsolate()); |
4101 xValue = v8::Persistent<Value>(); | 4103 xValue = v8::Persistent<Value>(); |
4102 } | 4104 } |
4103 } | 4105 } |
4104 | 4106 |
4105 | 4107 |
4106 THREADED_TEST(SetterOnly) { | 4108 THREADED_TEST(SetterOnly) { |
4107 v8::HandleScope scope; | 4109 v8::HandleScope scope; |
4108 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4110 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4109 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); | 4111 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
4110 LocalContext context; | 4112 LocalContext context; |
4111 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 4113 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
4112 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 4114 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
4113 for (int i = 0; i < 10; i++) { | 4115 for (int i = 0; i < 10; i++) { |
4114 CHECK(xValue.IsEmpty()); | 4116 CHECK(xValue.IsEmpty()); |
4115 script->Run(); | 4117 script->Run(); |
4116 CHECK_EQ(v8_num(4), xValue); | 4118 CHECK_EQ(v8_num(4), xValue); |
4117 xValue.Dispose(); | 4119 xValue.Dispose(context->GetIsolate()); |
4118 xValue = v8::Persistent<Value>(); | 4120 xValue = v8::Persistent<Value>(); |
4119 } | 4121 } |
4120 } | 4122 } |
4121 | 4123 |
4122 | 4124 |
4123 THREADED_TEST(NoAccessors) { | 4125 THREADED_TEST(NoAccessors) { |
4124 v8::HandleScope scope; | 4126 v8::HandleScope scope; |
4125 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4127 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4126 templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut")); | 4128 templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut")); |
4127 LocalContext context; | 4129 LocalContext context; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4217 // Check that the interceptor was actually invoked. | 4219 // Check that the interceptor was actually invoked. |
4218 CHECK_EQ(result, v8_str("x")); | 4220 CHECK_EQ(result, v8_str("x")); |
4219 } | 4221 } |
4220 | 4222 |
4221 // Return to the original context and force some object to the slow case | 4223 // Return to the original context and force some object to the slow case |
4222 // to cause the NormalizedMapCache to verify. | 4224 // to cause the NormalizedMapCache to verify. |
4223 context1->Enter(); | 4225 context1->Enter(); |
4224 CompileRun("var obj = { x : 0 }; delete obj.x;"); | 4226 CompileRun("var obj = { x : 0 }; delete obj.x;"); |
4225 context1->Exit(); | 4227 context1->Exit(); |
4226 | 4228 |
4227 context1.Dispose(); | 4229 context1.Dispose(context1->GetIsolate()); |
4228 } | 4230 } |
4229 | 4231 |
4230 | 4232 |
4231 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property, | 4233 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property, |
4232 const AccessorInfo& info) { | 4234 const AccessorInfo& info) { |
4233 // Set x on the prototype object and do not handle the get request. | 4235 // Set x on the prototype object and do not handle the get request. |
4234 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 4236 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
4235 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 4237 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); |
4236 return v8::Handle<Value>(); | 4238 return v8::Handle<Value>(); |
4237 } | 4239 } |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4999 | 5001 |
5000 | 5002 |
5001 THREADED_TEST(GlobalObjectTemplate) { | 5003 THREADED_TEST(GlobalObjectTemplate) { |
5002 v8::HandleScope handle_scope; | 5004 v8::HandleScope handle_scope; |
5003 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 5005 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
5004 global_template->Set(v8_str("JSNI_Log"), | 5006 global_template->Set(v8_str("JSNI_Log"), |
5005 v8::FunctionTemplate::New(HandleLogDelegator)); | 5007 v8::FunctionTemplate::New(HandleLogDelegator)); |
5006 v8::Persistent<Context> context = Context::New(0, global_template); | 5008 v8::Persistent<Context> context = Context::New(0, global_template); |
5007 Context::Scope context_scope(context); | 5009 Context::Scope context_scope(context); |
5008 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); | 5010 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); |
5009 context.Dispose(); | 5011 context.Dispose(context->GetIsolate()); |
5010 } | 5012 } |
5011 | 5013 |
5012 | 5014 |
5013 static const char* kSimpleExtensionSource = | 5015 static const char* kSimpleExtensionSource = |
5014 "function Foo() {" | 5016 "function Foo() {" |
5015 " return 4;" | 5017 " return 4;" |
5016 "}"; | 5018 "}"; |
5017 | 5019 |
5018 | 5020 |
5019 THREADED_TEST(SimpleExtensions) { | 5021 THREADED_TEST(SimpleExtensions) { |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5472 Snorkel() { index_ = global_index++; } | 5474 Snorkel() { index_ = global_index++; } |
5473 int index_; | 5475 int index_; |
5474 }; | 5476 }; |
5475 | 5477 |
5476 class Whammy { | 5478 class Whammy { |
5477 public: | 5479 public: |
5478 Whammy() { | 5480 Whammy() { |
5479 cursor_ = 0; | 5481 cursor_ = 0; |
5480 } | 5482 } |
5481 ~Whammy() { | 5483 ~Whammy() { |
5482 script_.Dispose(); | 5484 script_.Dispose(v8::Isolate::GetCurrent()); |
5483 } | 5485 } |
5484 v8::Handle<Script> getScript() { | 5486 v8::Handle<Script> getScript() { |
5485 if (script_.IsEmpty()) | 5487 if (script_.IsEmpty()) |
5486 script_ = v8::Persistent<Script>::New(v8_compile("({}).blammo")); | 5488 script_ = v8::Persistent<Script>::New(v8_compile("({}).blammo")); |
5487 return Local<Script>(*script_); | 5489 return Local<Script>(*script_); |
5488 } | 5490 } |
5489 | 5491 |
5490 public: | 5492 public: |
5491 static const int kObjectCount = 256; | 5493 static const int kObjectCount = 256; |
5492 int cursor_; | 5494 int cursor_; |
5493 v8::Persistent<v8::Object> objects_[kObjectCount]; | 5495 v8::Persistent<v8::Object> objects_[kObjectCount]; |
5494 v8::Persistent<Script> script_; | 5496 v8::Persistent<Script> script_; |
5495 }; | 5497 }; |
5496 | 5498 |
5497 static void HandleWeakReference(v8::Persistent<v8::Value> obj, void* data) { | 5499 static void HandleWeakReference(v8::Isolate* isolate, |
5500 v8::Persistent<v8::Value> obj, | |
5501 void* data) { | |
5498 Snorkel* snorkel = reinterpret_cast<Snorkel*>(data); | 5502 Snorkel* snorkel = reinterpret_cast<Snorkel*>(data); |
5499 delete snorkel; | 5503 delete snorkel; |
5500 obj.ClearWeak(); | 5504 obj.ClearWeak(isolate); |
5501 } | 5505 } |
5502 | 5506 |
5503 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, | 5507 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, |
5504 const AccessorInfo& info) { | 5508 const AccessorInfo& info) { |
5505 Whammy* whammy = | 5509 Whammy* whammy = |
5506 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); | 5510 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); |
5507 | 5511 |
5508 v8::Persistent<v8::Object> prev = whammy->objects_[whammy->cursor_]; | 5512 v8::Persistent<v8::Object> prev = whammy->objects_[whammy->cursor_]; |
5509 | 5513 |
5510 v8::Handle<v8::Object> obj = v8::Object::New(); | 5514 v8::Handle<v8::Object> obj = v8::Object::New(); |
5511 v8::Persistent<v8::Object> global = v8::Persistent<v8::Object>::New(obj); | 5515 v8::Persistent<v8::Object> global = v8::Persistent<v8::Object>::New(obj); |
5512 if (!prev.IsEmpty()) { | 5516 if (!prev.IsEmpty()) { |
5513 prev->Set(v8_str("next"), obj); | 5517 prev->Set(v8_str("next"), obj); |
5514 prev.MakeWeak(new Snorkel(), &HandleWeakReference); | 5518 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
5519 prev.MakeWeak(isolate, new Snorkel(), &HandleWeakReference); | |
Michael Starzinger
2013/01/24 13:09:05
Can we use info.GetIsolate() here?
Sven Panne
2013/01/25 08:28:40
Done.
| |
5515 whammy->objects_[whammy->cursor_].Clear(); | 5520 whammy->objects_[whammy->cursor_].Clear(); |
5516 } | 5521 } |
5517 whammy->objects_[whammy->cursor_] = global; | 5522 whammy->objects_[whammy->cursor_] = global; |
5518 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 5523 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
5519 return whammy->getScript()->Run(); | 5524 return whammy->getScript()->Run(); |
5520 } | 5525 } |
5521 | 5526 |
5522 THREADED_TEST(WeakReference) { | 5527 THREADED_TEST(WeakReference) { |
5523 v8::HandleScope handle_scope; | 5528 v8::HandleScope handle_scope; |
5524 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 5529 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
(...skipping 13 matching lines...) Expand all Loading... | |
5538 "for (var i = 0; i < 10000; i++) {" | 5543 "for (var i = 0; i < 10000; i++) {" |
5539 " var obj = whammy.length;" | 5544 " var obj = whammy.length;" |
5540 " if (last) last.next = obj;" | 5545 " if (last) last.next = obj;" |
5541 " last = obj;" | 5546 " last = obj;" |
5542 "}" | 5547 "}" |
5543 "gc();" | 5548 "gc();" |
5544 "4"; | 5549 "4"; |
5545 v8::Handle<Value> result = CompileRun(code); | 5550 v8::Handle<Value> result = CompileRun(code); |
5546 CHECK_EQ(4.0, result->NumberValue()); | 5551 CHECK_EQ(4.0, result->NumberValue()); |
5547 delete whammy; | 5552 delete whammy; |
5548 context.Dispose(); | 5553 context.Dispose(context->GetIsolate()); |
5549 } | 5554 } |
5550 | 5555 |
5551 | 5556 |
5552 static void DisposeAndSetFlag(v8::Persistent<v8::Value> obj, void* data) { | 5557 static void DisposeAndSetFlag(v8::Isolate* isolate, |
5553 obj.Dispose(); | 5558 v8::Persistent<v8::Value> obj, |
5559 void* data) { | |
5560 obj.Dispose(isolate); | |
5554 obj.Clear(); | 5561 obj.Clear(); |
5555 *(reinterpret_cast<bool*>(data)) = true; | 5562 *(reinterpret_cast<bool*>(data)) = true; |
5556 } | 5563 } |
5557 | 5564 |
5558 | 5565 |
5559 THREADED_TEST(IndependentWeakHandle) { | 5566 THREADED_TEST(IndependentWeakHandle) { |
5560 v8::Persistent<Context> context = Context::New(); | 5567 v8::Persistent<Context> context = Context::New(); |
5568 v8::Isolate* iso = context->GetIsolate(); | |
5561 Context::Scope context_scope(context); | 5569 Context::Scope context_scope(context); |
5562 | 5570 |
5563 v8::Persistent<v8::Object> object_a, object_b; | 5571 v8::Persistent<v8::Object> object_a, object_b; |
5564 | 5572 |
5565 { | 5573 { |
5566 v8::HandleScope handle_scope; | 5574 v8::HandleScope handle_scope; |
5567 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5575 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); |
5568 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5576 object_b = v8::Persistent<v8::Object>::New(v8::Object::New()); |
5569 } | 5577 } |
5570 | 5578 |
5571 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
5572 bool object_a_disposed = false; | 5579 bool object_a_disposed = false; |
5573 bool object_b_disposed = false; | 5580 bool object_b_disposed = false; |
5574 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); | 5581 object_a.MakeWeak(iso, &object_a_disposed, &DisposeAndSetFlag); |
5575 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag); | 5582 object_b.MakeWeak(iso, &object_b_disposed, &DisposeAndSetFlag); |
5576 CHECK(!object_a.IsIndependent()); | 5583 CHECK(!object_b.IsIndependent(iso)); |
5577 CHECK(!object_b.IsIndependent(isolate)); | 5584 object_a.MarkIndependent(iso); |
5578 object_a.MarkIndependent(); | 5585 object_b.MarkIndependent(iso); |
5579 object_b.MarkIndependent(isolate); | 5586 CHECK(object_b.IsIndependent(iso)); |
5580 CHECK(object_a.IsIndependent()); | |
5581 CHECK(object_b.IsIndependent(isolate)); | |
5582 HEAP->PerformScavenge(); | 5587 HEAP->PerformScavenge(); |
5583 CHECK(object_a_disposed); | 5588 CHECK(object_a_disposed); |
5584 CHECK(object_b_disposed); | 5589 CHECK(object_b_disposed); |
5585 } | 5590 } |
5586 | 5591 |
5587 | 5592 |
5588 static void InvokeScavenge() { | 5593 static void InvokeScavenge() { |
5589 HEAP->PerformScavenge(); | 5594 HEAP->PerformScavenge(); |
5590 } | 5595 } |
5591 | 5596 |
5592 | 5597 |
5593 static void InvokeMarkSweep() { | 5598 static void InvokeMarkSweep() { |
5594 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 5599 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
5595 } | 5600 } |
5596 | 5601 |
5597 | 5602 |
5598 static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) { | 5603 static void ForceScavenge(v8::Isolate* isolate, |
5599 obj.Dispose(); | 5604 v8::Persistent<v8::Value> obj, |
5605 void* data) { | |
5606 obj.Dispose(isolate); | |
5600 obj.Clear(); | 5607 obj.Clear(); |
5601 *(reinterpret_cast<bool*>(data)) = true; | 5608 *(reinterpret_cast<bool*>(data)) = true; |
5602 InvokeScavenge(); | 5609 InvokeScavenge(); |
5603 } | 5610 } |
5604 | 5611 |
5605 | 5612 |
5606 static void ForceMarkSweep(v8::Persistent<v8::Value> obj, void* data) { | 5613 static void ForceMarkSweep(v8::Isolate* isolate, |
5607 obj.Dispose(); | 5614 v8::Persistent<v8::Value> obj, |
5615 void* data) { | |
5616 obj.Dispose(isolate); | |
5608 obj.Clear(); | 5617 obj.Clear(); |
5609 *(reinterpret_cast<bool*>(data)) = true; | 5618 *(reinterpret_cast<bool*>(data)) = true; |
5610 InvokeMarkSweep(); | 5619 InvokeMarkSweep(); |
5611 } | 5620 } |
5612 | 5621 |
5613 | 5622 |
5614 THREADED_TEST(GCFromWeakCallbacks) { | 5623 THREADED_TEST(GCFromWeakCallbacks) { |
5615 v8::Persistent<Context> context = Context::New(); | 5624 v8::Persistent<Context> context = Context::New(); |
5616 Context::Scope context_scope(context); | 5625 Context::Scope context_scope(context); |
5617 | 5626 |
5618 static const int kNumberOfGCTypes = 2; | 5627 static const int kNumberOfGCTypes = 2; |
5619 v8::WeakReferenceCallback gc_forcing_callback[kNumberOfGCTypes] = | 5628 v8::NearDeathCallback gc_forcing_callback[kNumberOfGCTypes] = |
5620 {&ForceScavenge, &ForceMarkSweep}; | 5629 {&ForceScavenge, &ForceMarkSweep}; |
5621 | 5630 |
5622 typedef void (*GCInvoker)(); | 5631 typedef void (*GCInvoker)(); |
5623 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; | 5632 GCInvoker invoke_gc[kNumberOfGCTypes] = {&InvokeScavenge, &InvokeMarkSweep}; |
5624 | 5633 |
5625 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { | 5634 for (int outer_gc = 0; outer_gc < kNumberOfGCTypes; outer_gc++) { |
5626 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { | 5635 for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) { |
5627 v8::Persistent<v8::Object> object; | 5636 v8::Persistent<v8::Object> object; |
5628 { | 5637 { |
5629 v8::HandleScope handle_scope; | 5638 v8::HandleScope handle_scope; |
5630 object = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5639 object = v8::Persistent<v8::Object>::New(v8::Object::New()); |
5631 } | 5640 } |
5632 bool disposed = false; | 5641 bool disposed = false; |
5633 object.MakeWeak(&disposed, gc_forcing_callback[inner_gc]); | 5642 v8::Isolate* isolate = context->GetIsolate(); |
5634 object.MarkIndependent(); | 5643 object.MakeWeak(isolate, &disposed, gc_forcing_callback[inner_gc]); |
5644 object.MarkIndependent(isolate); | |
5635 invoke_gc[outer_gc](); | 5645 invoke_gc[outer_gc](); |
5636 CHECK(disposed); | 5646 CHECK(disposed); |
5637 } | 5647 } |
5638 } | 5648 } |
5639 } | 5649 } |
5640 | 5650 |
5641 | 5651 |
5642 static void RevivingCallback(v8::Persistent<v8::Value> obj, void* data) { | 5652 static void RevivingCallback(v8::Isolate* isolate, |
5643 obj.ClearWeak(); | 5653 v8::Persistent<v8::Value> obj, |
5654 void* data) { | |
5655 obj.ClearWeak(isolate); | |
5644 *(reinterpret_cast<bool*>(data)) = true; | 5656 *(reinterpret_cast<bool*>(data)) = true; |
5645 } | 5657 } |
5646 | 5658 |
5647 | 5659 |
5648 THREADED_TEST(IndependentHandleRevival) { | 5660 THREADED_TEST(IndependentHandleRevival) { |
5649 v8::Persistent<Context> context = Context::New(); | 5661 v8::Persistent<Context> context = Context::New(); |
5650 Context::Scope context_scope(context); | 5662 Context::Scope context_scope(context); |
5663 v8::Isolate* isolate = context->GetIsolate(); | |
5651 | 5664 |
5652 v8::Persistent<v8::Object> object; | 5665 v8::Persistent<v8::Object> object; |
5653 { | 5666 { |
5654 v8::HandleScope handle_scope; | 5667 v8::HandleScope handle_scope; |
5655 object = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5668 object = v8::Persistent<v8::Object>::New(v8::Object::New()); |
5656 object->Set(v8_str("x"), v8::Integer::New(1)); | 5669 object->Set(v8_str("x"), v8::Integer::New(1)); |
5657 v8::Local<String> y_str = v8_str("y"); | 5670 v8::Local<String> y_str = v8_str("y"); |
5658 object->Set(y_str, y_str); | 5671 object->Set(y_str, y_str); |
5659 } | 5672 } |
5660 bool revived = false; | 5673 bool revived = false; |
5661 object.MakeWeak(&revived, &RevivingCallback); | 5674 object.MakeWeak(isolate, &revived, &RevivingCallback); |
5662 object.MarkIndependent(); | 5675 object.MarkIndependent(isolate); |
5663 HEAP->PerformScavenge(); | 5676 HEAP->PerformScavenge(); |
5664 CHECK(revived); | 5677 CHECK(revived); |
5665 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 5678 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
5666 { | 5679 { |
5667 v8::HandleScope handle_scope; | 5680 v8::HandleScope handle_scope; |
5668 v8::Local<String> y_str = v8_str("y"); | 5681 v8::Local<String> y_str = v8_str("y"); |
5669 CHECK_EQ(v8::Integer::New(1), object->Get(v8_str("x"))); | 5682 CHECK_EQ(v8::Integer::New(1), object->Get(v8_str("x"))); |
5670 CHECK(object->Get(y_str)->Equals(y_str)); | 5683 CHECK(object->Get(y_str)->Equals(y_str)); |
5671 } | 5684 } |
5672 } | 5685 } |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6748 v8::Handle<Script> script2 = | 6761 v8::Handle<Script> script2 = |
6749 v8_compile("othercontext.foo = 333; othercontext[0] = 888;"); | 6762 v8_compile("othercontext.foo = 333; othercontext[0] = 888;"); |
6750 script2->Run(); | 6763 script2->Run(); |
6751 v8::Handle<Value> foo2 = global0->Get(v8_str("foo")); | 6764 v8::Handle<Value> foo2 = global0->Get(v8_str("foo")); |
6752 CHECK_EQ(333, foo2->Int32Value()); | 6765 CHECK_EQ(333, foo2->Int32Value()); |
6753 v8::Handle<Value> z2 = global0->Get(v8_str("0")); | 6766 v8::Handle<Value> z2 = global0->Get(v8_str("0")); |
6754 CHECK_EQ(888, z2->Int32Value()); | 6767 CHECK_EQ(888, z2->Int32Value()); |
6755 } | 6768 } |
6756 | 6769 |
6757 context1->Exit(); | 6770 context1->Exit(); |
6758 context1.Dispose(); | 6771 context1.Dispose(context1->GetIsolate()); |
6759 | 6772 |
6760 context0->Exit(); | 6773 context0->Exit(); |
6761 context0.Dispose(); | 6774 context0.Dispose(context0->GetIsolate()); |
6762 } | 6775 } |
6763 | 6776 |
6764 | 6777 |
6765 THREADED_TEST(SecurityChecks) { | 6778 THREADED_TEST(SecurityChecks) { |
6766 v8::HandleScope handle_scope; | 6779 v8::HandleScope handle_scope; |
6767 LocalContext env1; | 6780 LocalContext env1; |
6768 v8::Persistent<Context> env2 = Context::New(); | 6781 v8::Persistent<Context> env2 = Context::New(); |
6769 | 6782 |
6770 Local<Value> foo = v8_str("foo"); | 6783 Local<Value> foo = v8_str("foo"); |
6771 Local<Value> bar = v8_str("bar"); | 6784 Local<Value> bar = v8_str("bar"); |
(...skipping 23 matching lines...) Expand all Loading... | |
6795 { | 6808 { |
6796 env2->SetSecurityToken(bar); | 6809 env2->SetSecurityToken(bar); |
6797 Context::Scope scope_env2(env2); | 6810 Context::Scope scope_env2(env2); |
6798 | 6811 |
6799 // Call cross_domain_call, it should throw an exception | 6812 // Call cross_domain_call, it should throw an exception |
6800 v8::TryCatch try_catch; | 6813 v8::TryCatch try_catch; |
6801 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL); | 6814 Function::Cast(*spy2)->Call(env2->Global(), 0, NULL); |
6802 CHECK(try_catch.HasCaught()); | 6815 CHECK(try_catch.HasCaught()); |
6803 } | 6816 } |
6804 | 6817 |
6805 env2.Dispose(); | 6818 env2.Dispose(env2->GetIsolate()); |
6806 } | 6819 } |
6807 | 6820 |
6808 | 6821 |
6809 // Regression test case for issue 1183439. | 6822 // Regression test case for issue 1183439. |
6810 THREADED_TEST(SecurityChecksForPrototypeChain) { | 6823 THREADED_TEST(SecurityChecksForPrototypeChain) { |
6811 v8::HandleScope scope; | 6824 v8::HandleScope scope; |
6812 LocalContext current; | 6825 LocalContext current; |
6813 v8::Persistent<Context> other = Context::New(); | 6826 v8::Persistent<Context> other = Context::New(); |
6814 | 6827 |
6815 // Change context to be able to get to the Object function in the | 6828 // Change context to be able to get to the Object function in the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6864 // Try to read the properties from f and make sure that the access | 6877 // Try to read the properties from f and make sure that the access |
6865 // gets stopped by the security checks on the other global object. | 6878 // gets stopped by the security checks on the other global object. |
6866 Local<Script> access_f2 = v8_compile("f.foo"); | 6879 Local<Script> access_f2 = v8_compile("f.foo"); |
6867 Local<Script> access_f3 = v8_compile("f[99]"); | 6880 Local<Script> access_f3 = v8_compile("f[99]"); |
6868 for (int k = 0; k < 5; k++) { | 6881 for (int k = 0; k < 5; k++) { |
6869 CHECK(!access_f2->Run()->Equals(v8_num(100))); | 6882 CHECK(!access_f2->Run()->Equals(v8_num(100))); |
6870 CHECK(access_f2->Run()->IsUndefined()); | 6883 CHECK(access_f2->Run()->IsUndefined()); |
6871 CHECK(!access_f3->Run()->Equals(v8_num(101))); | 6884 CHECK(!access_f3->Run()->Equals(v8_num(101))); |
6872 CHECK(access_f3->Run()->IsUndefined()); | 6885 CHECK(access_f3->Run()->IsUndefined()); |
6873 } | 6886 } |
6874 other.Dispose(); | 6887 other.Dispose(other->GetIsolate()); |
6875 } | 6888 } |
6876 | 6889 |
6877 | 6890 |
6878 THREADED_TEST(CrossDomainDelete) { | 6891 THREADED_TEST(CrossDomainDelete) { |
6879 v8::HandleScope handle_scope; | 6892 v8::HandleScope handle_scope; |
6880 LocalContext env1; | 6893 LocalContext env1; |
6881 v8::Persistent<Context> env2 = Context::New(); | 6894 v8::Persistent<Context> env2 = Context::New(); |
6882 | 6895 |
6883 Local<Value> foo = v8_str("foo"); | 6896 Local<Value> foo = v8_str("foo"); |
6884 Local<Value> bar = v8_str("bar"); | 6897 Local<Value> bar = v8_str("bar"); |
(...skipping 12 matching lines...) Expand all Loading... | |
6897 Local<Value> result = | 6910 Local<Value> result = |
6898 Script::Compile(v8_str("delete env1.prop"))->Run(); | 6911 Script::Compile(v8_str("delete env1.prop"))->Run(); |
6899 CHECK(result->IsFalse()); | 6912 CHECK(result->IsFalse()); |
6900 } | 6913 } |
6901 | 6914 |
6902 // Check that env1.prop still exists. | 6915 // Check that env1.prop still exists. |
6903 Local<Value> v = env1->Global()->Get(v8_str("prop")); | 6916 Local<Value> v = env1->Global()->Get(v8_str("prop")); |
6904 CHECK(v->IsNumber()); | 6917 CHECK(v->IsNumber()); |
6905 CHECK_EQ(3, v->Int32Value()); | 6918 CHECK_EQ(3, v->Int32Value()); |
6906 | 6919 |
6907 env2.Dispose(); | 6920 env2.Dispose(env2->GetIsolate()); |
6908 } | 6921 } |
6909 | 6922 |
6910 | 6923 |
6911 THREADED_TEST(CrossDomainIsPropertyEnumerable) { | 6924 THREADED_TEST(CrossDomainIsPropertyEnumerable) { |
6912 v8::HandleScope handle_scope; | 6925 v8::HandleScope handle_scope; |
6913 LocalContext env1; | 6926 LocalContext env1; |
6914 v8::Persistent<Context> env2 = Context::New(); | 6927 v8::Persistent<Context> env2 = Context::New(); |
6915 | 6928 |
6916 Local<Value> foo = v8_str("foo"); | 6929 Local<Value> foo = v8_str("foo"); |
6917 Local<Value> bar = v8_str("bar"); | 6930 Local<Value> bar = v8_str("bar"); |
(...skipping 14 matching lines...) Expand all Loading... | |
6932 } | 6945 } |
6933 | 6946 |
6934 // Change env2 to a different domain and test again. | 6947 // Change env2 to a different domain and test again. |
6935 env2->SetSecurityToken(bar); | 6948 env2->SetSecurityToken(bar); |
6936 { | 6949 { |
6937 Context::Scope scope_env2(env2); | 6950 Context::Scope scope_env2(env2); |
6938 Local<Value> result = Script::Compile(test)->Run(); | 6951 Local<Value> result = Script::Compile(test)->Run(); |
6939 CHECK(result->IsFalse()); | 6952 CHECK(result->IsFalse()); |
6940 } | 6953 } |
6941 | 6954 |
6942 env2.Dispose(); | 6955 env2.Dispose(env2->GetIsolate()); |
6943 } | 6956 } |
6944 | 6957 |
6945 | 6958 |
6946 THREADED_TEST(CrossDomainForIn) { | 6959 THREADED_TEST(CrossDomainForIn) { |
6947 v8::HandleScope handle_scope; | 6960 v8::HandleScope handle_scope; |
6948 LocalContext env1; | 6961 LocalContext env1; |
6949 v8::Persistent<Context> env2 = Context::New(); | 6962 v8::Persistent<Context> env2 = Context::New(); |
6950 | 6963 |
6951 Local<Value> foo = v8_str("foo"); | 6964 Local<Value> foo = v8_str("foo"); |
6952 Local<Value> bar = v8_str("bar"); | 6965 Local<Value> bar = v8_str("bar"); |
(...skipping 12 matching lines...) Expand all Loading... | |
6965 env2->SetSecurityToken(bar); | 6978 env2->SetSecurityToken(bar); |
6966 { | 6979 { |
6967 Context::Scope scope_env2(env2); | 6980 Context::Scope scope_env2(env2); |
6968 Local<Value> result = | 6981 Local<Value> result = |
6969 CompileRun("(function(){var obj = {'__proto__':env1};" | 6982 CompileRun("(function(){var obj = {'__proto__':env1};" |
6970 "for (var p in obj)" | 6983 "for (var p in obj)" |
6971 " if (p == 'prop') return false;" | 6984 " if (p == 'prop') return false;" |
6972 "return true;})()"); | 6985 "return true;})()"); |
6973 CHECK(result->IsTrue()); | 6986 CHECK(result->IsTrue()); |
6974 } | 6987 } |
6975 env2.Dispose(); | 6988 env2.Dispose(env2->GetIsolate()); |
6976 } | 6989 } |
6977 | 6990 |
6978 | 6991 |
6979 TEST(ContextDetachGlobal) { | 6992 TEST(ContextDetachGlobal) { |
6980 v8::HandleScope handle_scope; | 6993 v8::HandleScope handle_scope; |
6981 LocalContext env1; | 6994 LocalContext env1; |
6982 v8::Persistent<Context> env2 = Context::New(); | 6995 v8::Persistent<Context> env2 = Context::New(); |
6983 | 6996 |
6984 Local<v8::Object> global1 = env1->Global(); | 6997 Local<v8::Object> global1 = env1->Global(); |
6985 | 6998 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7028 CHECK(!try_catch.HasCaught()); | 7041 CHECK(!try_catch.HasCaught()); |
7029 CHECK_EQ(1, r->Int32Value()); | 7042 CHECK_EQ(1, r->Int32Value()); |
7030 } | 7043 } |
7031 | 7044 |
7032 // Check that env3 is not accessible from env1 | 7045 // Check that env3 is not accessible from env1 |
7033 { | 7046 { |
7034 Local<Value> r = global3->Get(v8_str("prop2")); | 7047 Local<Value> r = global3->Get(v8_str("prop2")); |
7035 CHECK(r->IsUndefined()); | 7048 CHECK(r->IsUndefined()); |
7036 } | 7049 } |
7037 | 7050 |
7038 env2.Dispose(); | 7051 env2.Dispose(env2->GetIsolate()); |
7039 env3.Dispose(); | 7052 env3.Dispose(env3->GetIsolate()); |
7040 } | 7053 } |
7041 | 7054 |
7042 | 7055 |
7043 TEST(DetachAndReattachGlobal) { | 7056 TEST(DetachAndReattachGlobal) { |
7044 v8::HandleScope scope; | 7057 v8::HandleScope scope; |
7045 LocalContext env1; | 7058 LocalContext env1; |
7046 | 7059 |
7047 // Create second environment. | 7060 // Create second environment. |
7048 v8::Persistent<Context> env2 = Context::New(); | 7061 v8::Persistent<Context> env2 = Context::New(); |
7049 | 7062 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7107 // Detach the global for env3 and reattach it to env2. | 7120 // Detach the global for env3 and reattach it to env2. |
7108 env3->DetachGlobal(); | 7121 env3->DetachGlobal(); |
7109 env2->ReattachGlobal(global2); | 7122 env2->ReattachGlobal(global2); |
7110 | 7123 |
7111 // Check that we have access to other.p again in env1. |other| is now | 7124 // Check that we have access to other.p again in env1. |other| is now |
7112 // the global object for env2 which has the same security token as env1. | 7125 // the global object for env2 which has the same security token as env1. |
7113 result = CompileRun("other.p"); | 7126 result = CompileRun("other.p"); |
7114 CHECK(result->IsInt32()); | 7127 CHECK(result->IsInt32()); |
7115 CHECK_EQ(42, result->Int32Value()); | 7128 CHECK_EQ(42, result->Int32Value()); |
7116 | 7129 |
7117 env2.Dispose(); | 7130 env2.Dispose(env2->GetIsolate()); |
7118 env3.Dispose(); | 7131 env3.Dispose(env3->GetIsolate()); |
7119 } | 7132 } |
7120 | 7133 |
7121 | 7134 |
7122 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false }; | 7135 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false }; |
7123 static bool NamedAccessBlocker(Local<v8::Object> global, | 7136 static bool NamedAccessBlocker(Local<v8::Object> global, |
7124 Local<Value> name, | 7137 Local<Value> name, |
7125 v8::AccessType type, | 7138 v8::AccessType type, |
7126 Local<Value> data) { | 7139 Local<Value> data) { |
7127 return Context::GetCurrent()->Global()->Equals(global) || | 7140 return Context::GetCurrent()->Global()->Equals(global) || |
7128 allowed_access_type[type]; | 7141 allowed_access_type[type]; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7398 CompileRun("(function(){var obj = {'__proto__':other};" | 7411 CompileRun("(function(){var obj = {'__proto__':other};" |
7399 "for (var p in obj)" | 7412 "for (var p in obj)" |
7400 " if (p == 'accessible_prop' || p == 'blocked_prop') {" | 7413 " if (p == 'accessible_prop' || p == 'blocked_prop') {" |
7401 " return false;" | 7414 " return false;" |
7402 " }" | 7415 " }" |
7403 "return true;})()"); | 7416 "return true;})()"); |
7404 CHECK(value->IsTrue()); | 7417 CHECK(value->IsTrue()); |
7405 | 7418 |
7406 context1->Exit(); | 7419 context1->Exit(); |
7407 context0->Exit(); | 7420 context0->Exit(); |
7408 context1.Dispose(); | 7421 context1.Dispose(context1->GetIsolate()); |
7409 context0.Dispose(); | 7422 context0.Dispose(context0->GetIsolate()); |
7410 } | 7423 } |
7411 | 7424 |
7412 | 7425 |
7413 TEST(AccessControlES5) { | 7426 TEST(AccessControlES5) { |
7414 v8::HandleScope handle_scope; | 7427 v8::HandleScope handle_scope; |
7415 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 7428 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
7416 | 7429 |
7417 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 7430 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
7418 IndexedAccessBlocker); | 7431 IndexedAccessBlocker); |
7419 | 7432 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7527 // proxy object. Accessing the object that requires access checks | 7540 // proxy object. Accessing the object that requires access checks |
7528 // is blocked by the access checks on the object itself. | 7541 // is blocked by the access checks on the object itself. |
7529 value = CompileRun("Object.getOwnPropertyNames(other).length == 0"); | 7542 value = CompileRun("Object.getOwnPropertyNames(other).length == 0"); |
7530 CHECK(value->IsTrue()); | 7543 CHECK(value->IsTrue()); |
7531 | 7544 |
7532 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); | 7545 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); |
7533 CHECK(value->IsTrue()); | 7546 CHECK(value->IsTrue()); |
7534 | 7547 |
7535 context1->Exit(); | 7548 context1->Exit(); |
7536 context0->Exit(); | 7549 context0->Exit(); |
7537 context1.Dispose(); | 7550 context1.Dispose(context1->GetIsolate()); |
7538 context0.Dispose(); | 7551 context0.Dispose(context0->GetIsolate()); |
7539 } | 7552 } |
7540 | 7553 |
7541 | 7554 |
7542 static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) { | 7555 static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) { |
7543 v8::Handle<v8::Array> result = v8::Array::New(1); | 7556 v8::Handle<v8::Array> result = v8::Array::New(1); |
7544 result->Set(0, v8_str("x")); | 7557 result->Set(0, v8_str("x")); |
7545 return result; | 7558 return result; |
7546 } | 7559 } |
7547 | 7560 |
7548 | 7561 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7611 // Should return 10, instead of 11 | 7624 // Should return 10, instead of 11 |
7612 v8::Handle<Value> value = v8_compile("other.accessible")->Run(); | 7625 v8::Handle<Value> value = v8_compile("other.accessible")->Run(); |
7613 CHECK(value->IsNumber()); | 7626 CHECK(value->IsNumber()); |
7614 CHECK_EQ(10, value->Int32Value()); | 7627 CHECK_EQ(10, value->Int32Value()); |
7615 | 7628 |
7616 value = v8_compile("other.unreachable")->Run(); | 7629 value = v8_compile("other.unreachable")->Run(); |
7617 CHECK(value->IsUndefined()); | 7630 CHECK(value->IsUndefined()); |
7618 | 7631 |
7619 context1->Exit(); | 7632 context1->Exit(); |
7620 context0->Exit(); | 7633 context0->Exit(); |
7621 context1.Dispose(); | 7634 context1.Dispose(context1->GetIsolate()); |
7622 context0.Dispose(); | 7635 context0.Dispose(context0->GetIsolate()); |
7623 } | 7636 } |
7624 | 7637 |
7625 | 7638 |
7626 static int named_access_count = 0; | 7639 static int named_access_count = 0; |
7627 static int indexed_access_count = 0; | 7640 static int indexed_access_count = 0; |
7628 | 7641 |
7629 static bool NamedAccessCounter(Local<v8::Object> global, | 7642 static bool NamedAccessCounter(Local<v8::Object> global, |
7630 Local<Value> name, | 7643 Local<Value> name, |
7631 v8::AccessType type, | 7644 v8::AccessType type, |
7632 Local<Value> data) { | 7645 Local<Value> data) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7746 | 7759 |
7747 // Force the call inline cache into dictionary probing mode. | 7760 // Force the call inline cache into dictionary probing mode. |
7748 CompileRun("o.f = function() {}; testCallNormal(o)"); | 7761 CompileRun("o.f = function() {}; testCallNormal(o)"); |
7749 // Test that the named access check is still called for each | 7762 // Test that the named access check is still called for each |
7750 // invocation of the function. | 7763 // invocation of the function. |
7751 value = CompileRun("testCallNormal(obj)"); | 7764 value = CompileRun("testCallNormal(obj)"); |
7752 CHECK_EQ(106, named_access_count); | 7765 CHECK_EQ(106, named_access_count); |
7753 | 7766 |
7754 context1->Exit(); | 7767 context1->Exit(); |
7755 context0->Exit(); | 7768 context0->Exit(); |
7756 context1.Dispose(); | 7769 context1.Dispose(context1->GetIsolate()); |
7757 context0.Dispose(); | 7770 context0.Dispose(context0->GetIsolate()); |
7758 } | 7771 } |
7759 | 7772 |
7760 | 7773 |
7761 static bool NamedAccessFlatten(Local<v8::Object> global, | 7774 static bool NamedAccessFlatten(Local<v8::Object> global, |
7762 Local<Value> name, | 7775 Local<Value> name, |
7763 v8::AccessType type, | 7776 v8::AccessType type, |
7764 Local<Value> data) { | 7777 Local<Value> data) { |
7765 char buf[100]; | 7778 char buf[100]; |
7766 int len; | 7779 int len; |
7767 | 7780 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7821 v8::Handle<v8::Object> global1 = context1->Global(); | 7834 v8::Handle<v8::Object> global1 = context1->Global(); |
7822 global1->Set(v8_str("obj"), object); | 7835 global1->Set(v8_str("obj"), object); |
7823 | 7836 |
7824 v8::Handle<Value> value; | 7837 v8::Handle<Value> value; |
7825 | 7838 |
7826 value = v8_compile("var p = 'as' + 'df';")->Run(); | 7839 value = v8_compile("var p = 'as' + 'df';")->Run(); |
7827 value = v8_compile("obj[p];")->Run(); | 7840 value = v8_compile("obj[p];")->Run(); |
7828 | 7841 |
7829 context1->Exit(); | 7842 context1->Exit(); |
7830 context0->Exit(); | 7843 context0->Exit(); |
7831 context1.Dispose(); | 7844 context1.Dispose(context1->GetIsolate()); |
7832 context0.Dispose(); | 7845 context0.Dispose(context0->GetIsolate()); |
7833 } | 7846 } |
7834 | 7847 |
7835 | 7848 |
7836 static v8::Handle<Value> AccessControlNamedGetter( | 7849 static v8::Handle<Value> AccessControlNamedGetter( |
7837 Local<String>, const AccessorInfo&) { | 7850 Local<String>, const AccessorInfo&) { |
7838 return v8::Integer::New(42); | 7851 return v8::Integer::New(42); |
7839 } | 7852 } |
7840 | 7853 |
7841 | 7854 |
7842 static v8::Handle<Value> AccessControlNamedSetter( | 7855 static v8::Handle<Value> AccessControlNamedSetter( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7913 // time eventhough there is an interceptor on the object. | 7926 // time eventhough there is an interceptor on the object. |
7914 value = v8_compile("for (var i = 0; i < 10; i++) obj[0] = 1;")->Run(); | 7927 value = v8_compile("for (var i = 0; i < 10; i++) obj[0] = 1;")->Run(); |
7915 value = v8_compile("for (var i = 0; i < 10; i++) obj[0];" | 7928 value = v8_compile("for (var i = 0; i < 10; i++) obj[0];" |
7916 "obj[0]")->Run(); | 7929 "obj[0]")->Run(); |
7917 CHECK(value->IsNumber()); | 7930 CHECK(value->IsNumber()); |
7918 CHECK_EQ(42, value->Int32Value()); | 7931 CHECK_EQ(42, value->Int32Value()); |
7919 CHECK_EQ(21, indexed_access_count); | 7932 CHECK_EQ(21, indexed_access_count); |
7920 | 7933 |
7921 context1->Exit(); | 7934 context1->Exit(); |
7922 context0->Exit(); | 7935 context0->Exit(); |
7923 context1.Dispose(); | 7936 context1.Dispose(context1->GetIsolate()); |
7924 context0.Dispose(); | 7937 context0.Dispose(context0->GetIsolate()); |
7925 } | 7938 } |
7926 | 7939 |
7927 | 7940 |
7928 THREADED_TEST(Version) { | 7941 THREADED_TEST(Version) { |
7929 v8::V8::GetVersion(); | 7942 v8::V8::GetVersion(); |
7930 } | 7943 } |
7931 | 7944 |
7932 | 7945 |
7933 static v8::Handle<Value> InstanceFunctionCallback(const v8::Arguments& args) { | 7946 static v8::Handle<Value> InstanceFunctionCallback(const v8::Arguments& args) { |
7934 ApiTestFuzzer::Fuzz(); | 7947 ApiTestFuzzer::Fuzz(); |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8804 context1->Global()->Set(v8_str("fun"), fun); | 8817 context1->Global()->Set(v8_str("fun"), fun); |
8805 v8::Handle<v8::Value> x_value = CompileRun("fun('x')"); | 8818 v8::Handle<v8::Value> x_value = CompileRun("fun('x')"); |
8806 CHECK_EQ(42, x_value->Int32Value()); | 8819 CHECK_EQ(42, x_value->Int32Value()); |
8807 context0->DetachGlobal(); | 8820 context0->DetachGlobal(); |
8808 v8::TryCatch catcher; | 8821 v8::TryCatch catcher; |
8809 x_value = CompileRun("fun('x')"); | 8822 x_value = CompileRun("fun('x')"); |
8810 CHECK(x_value.IsEmpty()); | 8823 CHECK(x_value.IsEmpty()); |
8811 CHECK(catcher.HasCaught()); | 8824 CHECK(catcher.HasCaught()); |
8812 context1->Exit(); | 8825 context1->Exit(); |
8813 | 8826 |
8814 context1.Dispose(); | 8827 context1.Dispose(context1->GetIsolate()); |
8815 context0.Dispose(); | 8828 context0.Dispose(context0->GetIsolate()); |
8816 } | 8829 } |
8817 | 8830 |
8818 | 8831 |
8819 THREADED_TEST(CrossLazyLoad) { | 8832 THREADED_TEST(CrossLazyLoad) { |
8820 v8::HandleScope scope; | 8833 v8::HandleScope scope; |
8821 LocalContext other; | 8834 LocalContext other; |
8822 LocalContext current; | 8835 LocalContext current; |
8823 | 8836 |
8824 Local<String> token = v8_str("<security token>"); | 8837 Local<String> token = v8_str("<security token>"); |
8825 other->SetSecurityToken(token); | 8838 other->SetSecurityToken(token); |
(...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11322 } | 11335 } |
11323 v8::V8::ContextDisposedNotification(); | 11336 v8::V8::ContextDisposedNotification(); |
11324 CheckSurvivingGlobalObjectsCount(0); | 11337 CheckSurvivingGlobalObjectsCount(0); |
11325 } | 11338 } |
11326 } | 11339 } |
11327 | 11340 |
11328 | 11341 |
11329 v8::Persistent<v8::Object> some_object; | 11342 v8::Persistent<v8::Object> some_object; |
11330 v8::Persistent<v8::Object> bad_handle; | 11343 v8::Persistent<v8::Object> bad_handle; |
11331 | 11344 |
11332 void NewPersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) { | 11345 void NewPersistentHandleCallback(v8::Isolate* isolate, |
11346 v8::Persistent<v8::Value> handle, | |
11347 void*) { | |
11333 v8::HandleScope scope; | 11348 v8::HandleScope scope; |
11334 bad_handle = v8::Persistent<v8::Object>::New(some_object); | 11349 bad_handle = v8::Persistent<v8::Object>::New(some_object); |
11335 handle.Dispose(); | 11350 handle.Dispose(isolate); |
11336 } | 11351 } |
11337 | 11352 |
11338 | 11353 |
11339 THREADED_TEST(NewPersistentHandleFromWeakCallback) { | 11354 THREADED_TEST(NewPersistentHandleFromWeakCallback) { |
11340 LocalContext context; | 11355 LocalContext context; |
11341 | 11356 |
11342 v8::Persistent<v8::Object> handle1, handle2; | 11357 v8::Persistent<v8::Object> handle1, handle2; |
11343 { | 11358 { |
11344 v8::HandleScope scope; | 11359 v8::HandleScope scope; |
11345 some_object = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11360 some_object = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11346 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11361 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11347 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11362 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11348 } | 11363 } |
11349 // Note: order is implementation dependent alas: currently | 11364 // Note: order is implementation dependent alas: currently |
11350 // global handle nodes are processed by PostGarbageCollectionProcessing | 11365 // global handle nodes are processed by PostGarbageCollectionProcessing |
11351 // in reverse allocation order, so if second allocated handle is deleted, | 11366 // in reverse allocation order, so if second allocated handle is deleted, |
11352 // weak callback of the first handle would be able to 'reallocate' it. | 11367 // weak callback of the first handle would be able to 'reallocate' it. |
11353 handle1.MakeWeak(NULL, NewPersistentHandleCallback); | 11368 v8::Isolate* isolate = context->GetIsolate(); |
11354 handle2.Dispose(); | 11369 handle1.MakeWeak(isolate, NULL, NewPersistentHandleCallback); |
11370 handle2.Dispose(isolate); | |
11355 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11371 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
11356 } | 11372 } |
11357 | 11373 |
11358 | 11374 |
11359 v8::Persistent<v8::Object> to_be_disposed; | 11375 v8::Persistent<v8::Object> to_be_disposed; |
11360 | 11376 |
11361 void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) { | 11377 void DisposeAndForceGcCallback(v8::Isolate* isolate, |
11362 to_be_disposed.Dispose(); | 11378 v8::Persistent<v8::Value> handle, |
11379 void*) { | |
11380 to_be_disposed.Dispose(isolate); | |
11363 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11381 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
11364 handle.Dispose(); | 11382 handle.Dispose(isolate); |
11365 } | 11383 } |
11366 | 11384 |
11367 | 11385 |
11368 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 11386 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
11369 LocalContext context; | 11387 LocalContext context; |
11370 | 11388 |
11371 v8::Persistent<v8::Object> handle1, handle2; | 11389 v8::Persistent<v8::Object> handle1, handle2; |
11372 { | 11390 { |
11373 v8::HandleScope scope; | 11391 v8::HandleScope scope; |
11374 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11392 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11375 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11393 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11376 } | 11394 } |
11377 handle1.MakeWeak(NULL, DisposeAndForceGcCallback); | 11395 handle1.MakeWeak(context->GetIsolate(), NULL, DisposeAndForceGcCallback); |
11378 to_be_disposed = handle2; | 11396 to_be_disposed = handle2; |
11379 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11397 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
11380 } | 11398 } |
11381 | 11399 |
11382 void DisposingCallback(v8::Persistent<v8::Value> handle, void*) { | 11400 void DisposingCallback(v8::Isolate* isolate, |
11383 handle.Dispose(); | 11401 v8::Persistent<v8::Value> handle, |
11402 void*) { | |
11403 handle.Dispose(isolate); | |
11384 } | 11404 } |
11385 | 11405 |
11386 void HandleCreatingCallback(v8::Persistent<v8::Value> handle, void*) { | 11406 void HandleCreatingCallback(v8::Isolate* isolate, |
11407 v8::Persistent<v8::Value> handle, | |
11408 void*) { | |
11387 v8::HandleScope scope; | 11409 v8::HandleScope scope; |
11388 v8::Persistent<v8::Object>::New(v8::Object::New()); | 11410 v8::Persistent<v8::Object>::New(v8::Object::New()); |
11389 handle.Dispose(); | 11411 handle.Dispose(isolate); |
11390 } | 11412 } |
11391 | 11413 |
11392 | 11414 |
11393 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { | 11415 THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { |
11394 LocalContext context; | 11416 LocalContext context; |
11417 v8::Isolate* isolate = context->GetIsolate(); | |
11395 | 11418 |
11396 v8::Persistent<v8::Object> handle1, handle2, handle3; | 11419 v8::Persistent<v8::Object> handle1, handle2, handle3; |
11397 { | 11420 { |
11398 v8::HandleScope scope; | 11421 v8::HandleScope scope; |
11399 handle3 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11422 handle3 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11400 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11423 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11401 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); | 11424 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New()); |
11402 } | 11425 } |
11403 handle2.MakeWeak(NULL, DisposingCallback); | 11426 handle2.MakeWeak(isolate, NULL, DisposingCallback); |
11404 handle3.MakeWeak(NULL, HandleCreatingCallback); | 11427 handle3.MakeWeak(isolate, NULL, HandleCreatingCallback); |
11405 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11428 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
11406 } | 11429 } |
11407 | 11430 |
11408 | 11431 |
11409 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 11432 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
11410 v8::V8::Initialize(); | 11433 v8::V8::Initialize(); |
11411 | 11434 |
11412 const int nof = 2; | 11435 const int nof = 2; |
11413 const char* sources[nof] = { | 11436 const char* sources[nof] = { |
11414 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 11437 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
(...skipping 25 matching lines...) Expand all Loading... | |
11440 | 11463 |
11441 | 11464 |
11442 THREADED_TEST(NestedHandleScopeAndContexts) { | 11465 THREADED_TEST(NestedHandleScopeAndContexts) { |
11443 v8::HandleScope outer; | 11466 v8::HandleScope outer; |
11444 v8::Persistent<Context> env = Context::New(); | 11467 v8::Persistent<Context> env = Context::New(); |
11445 env->Enter(); | 11468 env->Enter(); |
11446 v8::Handle<Value> value = NestedScope(env); | 11469 v8::Handle<Value> value = NestedScope(env); |
11447 v8::Handle<String> str(value->ToString()); | 11470 v8::Handle<String> str(value->ToString()); |
11448 CHECK(!str.IsEmpty()); | 11471 CHECK(!str.IsEmpty()); |
11449 env->Exit(); | 11472 env->Exit(); |
11450 env.Dispose(); | 11473 env.Dispose(env->GetIsolate()); |
11451 } | 11474 } |
11452 | 11475 |
11453 | 11476 |
11454 static i::Handle<i::JSFunction>* foo_ptr = NULL; | 11477 static i::Handle<i::JSFunction>* foo_ptr = NULL; |
11455 static int foo_count = 0; | 11478 static int foo_count = 0; |
11456 static i::Handle<i::JSFunction>* bar_ptr = NULL; | 11479 static i::Handle<i::JSFunction>* bar_ptr = NULL; |
11457 static int bar_count = 0; | 11480 static int bar_count = 0; |
11458 | 11481 |
11459 | 11482 |
11460 static void entry_hook(uintptr_t function, | 11483 static void entry_hook(uintptr_t function, |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11762 CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize)), | 11785 CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize)), |
11763 cast(0)); | 11786 cast(0)); |
11764 } | 11787 } |
11765 | 11788 |
11766 | 11789 |
11767 THREADED_TEST(DisposeEnteredContext) { | 11790 THREADED_TEST(DisposeEnteredContext) { |
11768 v8::HandleScope scope; | 11791 v8::HandleScope scope; |
11769 LocalContext outer; | 11792 LocalContext outer; |
11770 { v8::Persistent<v8::Context> inner = v8::Context::New(); | 11793 { v8::Persistent<v8::Context> inner = v8::Context::New(); |
11771 inner->Enter(); | 11794 inner->Enter(); |
11772 inner.Dispose(); | 11795 inner.Dispose(inner->GetIsolate()); |
11773 inner.Clear(); | 11796 inner.Clear(); |
11774 inner->Exit(); | 11797 inner->Exit(); |
11775 } | 11798 } |
11776 } | 11799 } |
11777 | 11800 |
11778 | 11801 |
11779 // Regression test for issue 54, object templates with internal fields | 11802 // Regression test for issue 54, object templates with internal fields |
11780 // but no accessors or interceptors did not get their internal field | 11803 // but no accessors or interceptors did not get their internal field |
11781 // count set on instances. | 11804 // count set on instances. |
11782 THREADED_TEST(Regress54) { | 11805 THREADED_TEST(Regress54) { |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12469 // Call the constructor function from context0 and check that the | 12492 // Call the constructor function from context0 and check that the |
12470 // result has the 'x' property. | 12493 // result has the 'x' property. |
12471 context1->Enter(); | 12494 context1->Enter(); |
12472 context1->Global()->Set(v8_str("other"), context0->Global()); | 12495 context1->Global()->Set(v8_str("other"), context0->Global()); |
12473 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); | 12496 Local<Value> value = CompileRun("var instance = new other.C(); instance.x"); |
12474 CHECK(value->IsInt32()); | 12497 CHECK(value->IsInt32()); |
12475 CHECK_EQ(42, value->Int32Value()); | 12498 CHECK_EQ(42, value->Int32Value()); |
12476 context1->Exit(); | 12499 context1->Exit(); |
12477 | 12500 |
12478 // Dispose the contexts to allow them to be garbage collected. | 12501 // Dispose the contexts to allow them to be garbage collected. |
12479 context0.Dispose(); | 12502 context0.Dispose(context0->GetIsolate()); |
12480 context1.Dispose(); | 12503 context1.Dispose(context1->GetIsolate()); |
12481 } | 12504 } |
12482 | 12505 |
12483 | 12506 |
12484 class RegExpInterruptTest { | 12507 class RegExpInterruptTest { |
12485 public: | 12508 public: |
12486 RegExpInterruptTest() : block_(NULL) {} | 12509 RegExpInterruptTest() : block_(NULL) {} |
12487 ~RegExpInterruptTest() { delete block_; } | 12510 ~RegExpInterruptTest() { delete block_; } |
12488 void RunTest() { | 12511 void RunTest() { |
12489 block_ = i::OS::CreateSemaphore(0); | 12512 block_ = i::OS::CreateSemaphore(0); |
12490 gc_count_ = 0; | 12513 gc_count_ = 0; |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13285 "(function() {" | 13308 "(function() {" |
13286 " try {" | 13309 " try {" |
13287 " return f();" | 13310 " return f();" |
13288 " } catch(e) {" | 13311 " } catch(e) {" |
13289 " return e.toString();" | 13312 " return e.toString();" |
13290 " }" | 13313 " }" |
13291 " })()", | 13314 " })()", |
13292 "ReferenceError: G is not defined"); | 13315 "ReferenceError: G is not defined"); |
13293 ctx2->Exit(); | 13316 ctx2->Exit(); |
13294 ctx1->Exit(); | 13317 ctx1->Exit(); |
13295 ctx1.Dispose(); | 13318 ctx1.Dispose(ctx1->GetIsolate()); |
13296 } | 13319 } |
13297 ctx2.Dispose(); | 13320 ctx2.Dispose(ctx2->GetIsolate()); |
13298 } | 13321 } |
13299 | 13322 |
13300 | 13323 |
13301 v8::Persistent<Context> calling_context0; | 13324 v8::Persistent<Context> calling_context0; |
13302 v8::Persistent<Context> calling_context1; | 13325 v8::Persistent<Context> calling_context1; |
13303 v8::Persistent<Context> calling_context2; | 13326 v8::Persistent<Context> calling_context2; |
13304 | 13327 |
13305 | 13328 |
13306 // Check that the call to the callback is initiated in | 13329 // Check that the call to the callback is initiated in |
13307 // calling_context2, the directly calling context is calling_context1 | 13330 // calling_context2, the directly calling context is calling_context1 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13346 | 13369 |
13347 // Expose context1 in context2 and call the callback function in | 13370 // Expose context1 in context2 and call the callback function in |
13348 // context0 indirectly through f in context1. | 13371 // context0 indirectly through f in context1. |
13349 calling_context2->Enter(); | 13372 calling_context2->Enter(); |
13350 calling_context2->Global()->Set(v8_str("context1"), | 13373 calling_context2->Global()->Set(v8_str("context1"), |
13351 calling_context1->Global()); | 13374 calling_context1->Global()); |
13352 CompileRun("context1.f()"); | 13375 CompileRun("context1.f()"); |
13353 calling_context2->Exit(); | 13376 calling_context2->Exit(); |
13354 | 13377 |
13355 // Dispose the contexts to allow them to be garbage collected. | 13378 // Dispose the contexts to allow them to be garbage collected. |
13356 calling_context0.Dispose(); | 13379 calling_context0.Dispose(calling_context0->GetIsolate()); |
13357 calling_context1.Dispose(); | 13380 calling_context1.Dispose(calling_context1->GetIsolate()); |
13358 calling_context2.Dispose(); | 13381 calling_context2.Dispose(calling_context2->GetIsolate()); |
13359 calling_context0.Clear(); | 13382 calling_context0.Clear(); |
13360 calling_context1.Clear(); | 13383 calling_context1.Clear(); |
13361 calling_context2.Clear(); | 13384 calling_context2.Clear(); |
13362 } | 13385 } |
13363 | 13386 |
13364 | 13387 |
13365 // Check that a variable declaration with no explicit initialization | 13388 // Check that a variable declaration with no explicit initialization |
13366 // value does shadow an existing property in the prototype chain. | 13389 // value does shadow an existing property in the prototype chain. |
13367 THREADED_TEST(InitGlobalVarInProtoChain) { | 13390 THREADED_TEST(InitGlobalVarInProtoChain) { |
13368 i::FLAG_es52_globals = true; | 13391 i::FLAG_es52_globals = true; |
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15070 LocalContext env; | 15093 LocalContext env; |
15071 intptr_t initial_size = HEAP->SizeOfObjects(); | 15094 intptr_t initial_size = HEAP->SizeOfObjects(); |
15072 // Send idle notification to start a round of incremental GCs. | 15095 // Send idle notification to start a round of incremental GCs. |
15073 v8::V8::IdleNotification(kShortIdlePauseInMs); | 15096 v8::V8::IdleNotification(kShortIdlePauseInMs); |
15074 // Emulate 7 page reloads. | 15097 // Emulate 7 page reloads. |
15075 for (int i = 0; i < 7; i++) { | 15098 for (int i = 0; i < 7; i++) { |
15076 v8::Persistent<v8::Context> ctx = v8::Context::New(); | 15099 v8::Persistent<v8::Context> ctx = v8::Context::New(); |
15077 ctx->Enter(); | 15100 ctx->Enter(); |
15078 CreateGarbageInOldSpace(); | 15101 CreateGarbageInOldSpace(); |
15079 ctx->Exit(); | 15102 ctx->Exit(); |
15080 ctx.Dispose(); | 15103 ctx.Dispose(ctx->GetIsolate()); |
15081 v8::V8::ContextDisposedNotification(); | 15104 v8::V8::ContextDisposedNotification(); |
15082 v8::V8::IdleNotification(kLongIdlePauseInMs); | 15105 v8::V8::IdleNotification(kLongIdlePauseInMs); |
15083 } | 15106 } |
15084 // Create garbage and check that idle notification still collects it. | 15107 // Create garbage and check that idle notification still collects it. |
15085 CreateGarbageInOldSpace(); | 15108 CreateGarbageInOldSpace(); |
15086 intptr_t size_with_garbage = HEAP->SizeOfObjects(); | 15109 intptr_t size_with_garbage = HEAP->SizeOfObjects(); |
15087 CHECK_GT(size_with_garbage, initial_size + MB); | 15110 CHECK_GT(size_with_garbage, initial_size + MB); |
15088 bool finished = false; | 15111 bool finished = false; |
15089 for (int i = 0; i < 200 && !finished; i++) { | 15112 for (int i = 0; i < 200 && !finished; i++) { |
15090 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); | 15113 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15422 context = Context::New(); | 15445 context = Context::New(); |
15423 { | 15446 { |
15424 v8::HandleScope scope; | 15447 v8::HandleScope scope; |
15425 | 15448 |
15426 context->Enter(); | 15449 context->Enter(); |
15427 Local<v8::String> obj = v8::String::New(""); | 15450 Local<v8::String> obj = v8::String::New(""); |
15428 context->SetEmbedderData(0, obj); | 15451 context->SetEmbedderData(0, obj); |
15429 CompileRun(source_simple); | 15452 CompileRun(source_simple); |
15430 context->Exit(); | 15453 context->Exit(); |
15431 } | 15454 } |
15432 context.Dispose(); | 15455 context.Dispose(context->GetIsolate()); |
15433 v8::V8::ContextDisposedNotification(); | 15456 v8::V8::ContextDisposedNotification(); |
15434 for (gc_count = 1; gc_count < 10; gc_count++) { | 15457 for (gc_count = 1; gc_count < 10; gc_count++) { |
15435 other_context->Enter(); | 15458 other_context->Enter(); |
15436 CompileRun(source_simple); | 15459 CompileRun(source_simple); |
15437 other_context->Exit(); | 15460 other_context->Exit(); |
15438 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15461 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
15439 if (GetGlobalObjectsCount() == 1) break; | 15462 if (GetGlobalObjectsCount() == 1) break; |
15440 } | 15463 } |
15441 CHECK_GE(2, gc_count); | 15464 CHECK_GE(2, gc_count); |
15442 CHECK_EQ(1, GetGlobalObjectsCount()); | 15465 CHECK_EQ(1, GetGlobalObjectsCount()); |
15443 | 15466 |
15444 // Eval in a function creates reference from the compilation cache to the | 15467 // Eval in a function creates reference from the compilation cache to the |
15445 // global object. | 15468 // global object. |
15446 const char* source_eval = "function f(){eval('1')}; f()"; | 15469 const char* source_eval = "function f(){eval('1')}; f()"; |
15447 context = Context::New(); | 15470 context = Context::New(); |
15448 { | 15471 { |
15449 v8::HandleScope scope; | 15472 v8::HandleScope scope; |
15450 | 15473 |
15451 context->Enter(); | 15474 context->Enter(); |
15452 CompileRun(source_eval); | 15475 CompileRun(source_eval); |
15453 context->Exit(); | 15476 context->Exit(); |
15454 } | 15477 } |
15455 context.Dispose(); | 15478 context.Dispose(context->GetIsolate()); |
15456 v8::V8::ContextDisposedNotification(); | 15479 v8::V8::ContextDisposedNotification(); |
15457 for (gc_count = 1; gc_count < 10; gc_count++) { | 15480 for (gc_count = 1; gc_count < 10; gc_count++) { |
15458 other_context->Enter(); | 15481 other_context->Enter(); |
15459 CompileRun(source_eval); | 15482 CompileRun(source_eval); |
15460 other_context->Exit(); | 15483 other_context->Exit(); |
15461 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15484 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
15462 if (GetGlobalObjectsCount() == 1) break; | 15485 if (GetGlobalObjectsCount() == 1) break; |
15463 } | 15486 } |
15464 CHECK_GE(2, gc_count); | 15487 CHECK_GE(2, gc_count); |
15465 CHECK_EQ(1, GetGlobalObjectsCount()); | 15488 CHECK_EQ(1, GetGlobalObjectsCount()); |
15466 | 15489 |
15467 // Looking up the line number for an exception creates reference from the | 15490 // Looking up the line number for an exception creates reference from the |
15468 // compilation cache to the global object. | 15491 // compilation cache to the global object. |
15469 const char* source_exception = "function f(){throw 1;} f()"; | 15492 const char* source_exception = "function f(){throw 1;} f()"; |
15470 context = Context::New(); | 15493 context = Context::New(); |
15471 { | 15494 { |
15472 v8::HandleScope scope; | 15495 v8::HandleScope scope; |
15473 | 15496 |
15474 context->Enter(); | 15497 context->Enter(); |
15475 v8::TryCatch try_catch; | 15498 v8::TryCatch try_catch; |
15476 CompileRun(source_exception); | 15499 CompileRun(source_exception); |
15477 CHECK(try_catch.HasCaught()); | 15500 CHECK(try_catch.HasCaught()); |
15478 v8::Handle<v8::Message> message = try_catch.Message(); | 15501 v8::Handle<v8::Message> message = try_catch.Message(); |
15479 CHECK(!message.IsEmpty()); | 15502 CHECK(!message.IsEmpty()); |
15480 CHECK_EQ(1, message->GetLineNumber()); | 15503 CHECK_EQ(1, message->GetLineNumber()); |
15481 context->Exit(); | 15504 context->Exit(); |
15482 } | 15505 } |
15483 context.Dispose(); | 15506 context.Dispose(context->GetIsolate()); |
15484 v8::V8::ContextDisposedNotification(); | 15507 v8::V8::ContextDisposedNotification(); |
15485 for (gc_count = 1; gc_count < 10; gc_count++) { | 15508 for (gc_count = 1; gc_count < 10; gc_count++) { |
15486 other_context->Enter(); | 15509 other_context->Enter(); |
15487 CompileRun(source_exception); | 15510 CompileRun(source_exception); |
15488 other_context->Exit(); | 15511 other_context->Exit(); |
15489 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15512 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
15490 if (GetGlobalObjectsCount() == 1) break; | 15513 if (GetGlobalObjectsCount() == 1) break; |
15491 } | 15514 } |
15492 CHECK_GE(2, gc_count); | 15515 CHECK_GE(2, gc_count); |
15493 CHECK_EQ(1, GetGlobalObjectsCount()); | 15516 CHECK_EQ(1, GetGlobalObjectsCount()); |
15494 | 15517 |
15495 other_context.Dispose(); | 15518 other_context.Dispose(other_context->GetIsolate()); |
15496 v8::V8::ContextDisposedNotification(); | 15519 v8::V8::ContextDisposedNotification(); |
15497 } | 15520 } |
15498 | 15521 |
15499 | 15522 |
15500 THREADED_TEST(ScriptOrigin) { | 15523 THREADED_TEST(ScriptOrigin) { |
15501 v8::HandleScope scope; | 15524 v8::HandleScope scope; |
15502 LocalContext env; | 15525 LocalContext env; |
15503 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | 15526 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); |
15504 v8::Handle<v8::String> script = v8::String::New( | 15527 v8::Handle<v8::String> script = v8::String::New( |
15505 "function f() {}\n\nfunction g() {}"); | 15528 "function f() {}\n\nfunction g() {}"); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16275 } | 16298 } |
16276 | 16299 |
16277 { | 16300 { |
16278 v8::Context::Scope cscope(context1); | 16301 v8::Context::Scope cscope(context1); |
16279 v8::HandleScope scope; | 16302 v8::HandleScope scope; |
16280 ExpectString("function f() { return foo; }; f()", "isolate 1"); | 16303 ExpectString("function f() { return foo; }; f()", "isolate 1"); |
16281 } | 16304 } |
16282 | 16305 |
16283 { | 16306 { |
16284 v8::Isolate::Scope iscope(isolate2); | 16307 v8::Isolate::Scope iscope(isolate2); |
16285 context2.Dispose(); | 16308 context2.Dispose(context2->GetIsolate()); |
16286 } | 16309 } |
16287 | 16310 |
16288 context1.Dispose(); | 16311 context1.Dispose(context1->GetIsolate()); |
16289 isolate1->Exit(); | 16312 isolate1->Exit(); |
16290 | 16313 |
16291 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 16314 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
16292 last_location = last_message = NULL; | 16315 last_location = last_message = NULL; |
16293 | 16316 |
16294 isolate1->Dispose(); | 16317 isolate1->Dispose(); |
16295 CHECK_EQ(last_location, NULL); | 16318 CHECK_EQ(last_location, NULL); |
16296 CHECK_EQ(last_message, NULL); | 16319 CHECK_EQ(last_message, NULL); |
16297 | 16320 |
16298 isolate2->Dispose(); | 16321 isolate2->Dispose(); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16652 public: | 16675 public: |
16653 explicit Visitor42(v8::Persistent<v8::Object> object) | 16676 explicit Visitor42(v8::Persistent<v8::Object> object) |
16654 : counter_(0), object_(object) { } | 16677 : counter_(0), object_(object) { } |
16655 | 16678 |
16656 virtual void VisitPersistentHandle(Persistent<Value> value, | 16679 virtual void VisitPersistentHandle(Persistent<Value> value, |
16657 uint16_t class_id) { | 16680 uint16_t class_id) { |
16658 if (class_id == 42) { | 16681 if (class_id == 42) { |
16659 CHECK(value->IsObject()); | 16682 CHECK(value->IsObject()); |
16660 v8::Persistent<v8::Object> visited = | 16683 v8::Persistent<v8::Object> visited = |
16661 v8::Persistent<v8::Object>::Cast(value); | 16684 v8::Persistent<v8::Object>::Cast(value); |
16662 CHECK_EQ(42, visited.WrapperClassId()); | 16685 CHECK_EQ(42, visited.WrapperClassId(v8::Isolate::GetCurrent())); |
16663 CHECK_EQ(object_, visited); | 16686 CHECK_EQ(object_, visited); |
16664 ++counter_; | 16687 ++counter_; |
16665 } | 16688 } |
16666 } | 16689 } |
16667 | 16690 |
16668 int counter_; | 16691 int counter_; |
16669 v8::Persistent<v8::Object> object_; | 16692 v8::Persistent<v8::Object> object_; |
16670 }; | 16693 }; |
16671 | 16694 |
16672 | 16695 |
16673 TEST(PersistentHandleVisitor) { | 16696 TEST(PersistentHandleVisitor) { |
16674 v8::HandleScope scope; | 16697 v8::HandleScope scope; |
16675 LocalContext context; | 16698 LocalContext context; |
16699 v8::Isolate* isolate = context->GetIsolate(); | |
16676 v8::Persistent<v8::Object> object = | 16700 v8::Persistent<v8::Object> object = |
16677 v8::Persistent<v8::Object>::New(v8::Object::New()); | 16701 v8::Persistent<v8::Object>::New(v8::Object::New()); |
16678 CHECK_EQ(0, object.WrapperClassId()); | 16702 CHECK_EQ(0, object.WrapperClassId(isolate)); |
16679 object.SetWrapperClassId(42); | 16703 object.SetWrapperClassId(42); |
16680 CHECK_EQ(42, object.WrapperClassId()); | 16704 CHECK_EQ(42, object.WrapperClassId(isolate)); |
16681 | 16705 |
16682 Visitor42 visitor(object); | 16706 Visitor42 visitor(object); |
16683 v8::V8::VisitHandlesWithClassIds(&visitor); | 16707 v8::V8::VisitHandlesWithClassIds(&visitor); |
16684 CHECK_EQ(1, visitor.counter_); | 16708 CHECK_EQ(1, visitor.counter_); |
16685 | 16709 |
16686 object.Dispose(); | 16710 object.Dispose(isolate); |
16687 } | 16711 } |
16688 | 16712 |
16689 | 16713 |
16690 TEST(WrapperClassId) { | 16714 TEST(WrapperClassId) { |
16691 v8::HandleScope scope; | 16715 v8::HandleScope scope; |
16692 LocalContext context; | 16716 LocalContext context; |
16717 v8::Isolate* isolate = context->GetIsolate(); | |
16693 v8::Persistent<v8::Object> object = | 16718 v8::Persistent<v8::Object> object = |
16694 v8::Persistent<v8::Object>::New(v8::Object::New()); | 16719 v8::Persistent<v8::Object>::New(v8::Object::New()); |
16695 CHECK_EQ(0, object.WrapperClassId()); | 16720 CHECK_EQ(0, object.WrapperClassId(isolate)); |
16696 object.SetWrapperClassId(65535); | 16721 object.SetWrapperClassId(65535); |
16697 CHECK_EQ(65535, object.WrapperClassId()); | 16722 CHECK_EQ(65535, object.WrapperClassId(isolate)); |
16698 object.Dispose(); | 16723 object.Dispose(isolate); |
16699 } | 16724 } |
16700 | 16725 |
16701 | 16726 |
16702 TEST(RegExp) { | 16727 TEST(RegExp) { |
16703 v8::HandleScope scope; | 16728 v8::HandleScope scope; |
16704 LocalContext context; | 16729 LocalContext context; |
16705 | 16730 |
16706 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); | 16731 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); |
16707 CHECK(re->IsRegExp()); | 16732 CHECK(re->IsRegExp()); |
16708 CHECK(re->GetSource()->Equals(v8_str("foo"))); | 16733 CHECK(re->GetSource()->Equals(v8_str("foo"))); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16918 CHECK(instance1->CreationContext() == context1); | 16943 CHECK(instance1->CreationContext() == context1); |
16919 CheckContextId(instance1, 1); | 16944 CheckContextId(instance1, 1); |
16920 CHECK(object2->CreationContext() == context2); | 16945 CHECK(object2->CreationContext() == context2); |
16921 CheckContextId(object2, 2); | 16946 CheckContextId(object2, 2); |
16922 CHECK(func2->CreationContext() == context2); | 16947 CHECK(func2->CreationContext() == context2); |
16923 CheckContextId(func2, 2); | 16948 CheckContextId(func2, 2); |
16924 CHECK(instance2->CreationContext() == context2); | 16949 CHECK(instance2->CreationContext() == context2); |
16925 CheckContextId(instance2, 2); | 16950 CheckContextId(instance2, 2); |
16926 } | 16951 } |
16927 | 16952 |
16928 context1.Dispose(); | 16953 context1.Dispose(context1->GetIsolate()); |
16929 context2.Dispose(); | 16954 context2.Dispose(context2->GetIsolate()); |
16930 context3.Dispose(); | 16955 context3.Dispose(context3->GetIsolate()); |
16931 } | 16956 } |
16932 | 16957 |
16933 | 16958 |
16934 THREADED_TEST(CreationContextOfJsFunction) { | 16959 THREADED_TEST(CreationContextOfJsFunction) { |
16935 HandleScope handle_scope; | 16960 HandleScope handle_scope; |
16936 Persistent<Context> context = Context::New(); | 16961 Persistent<Context> context = Context::New(); |
16937 InstallContextId(context, 1); | 16962 InstallContextId(context, 1); |
16938 | 16963 |
16939 Local<Object> function; | 16964 Local<Object> function; |
16940 { | 16965 { |
16941 Context::Scope scope(context); | 16966 Context::Scope scope(context); |
16942 function = CompileRun("function foo() {}; foo").As<Object>(); | 16967 function = CompileRun("function foo() {}; foo").As<Object>(); |
16943 } | 16968 } |
16944 | 16969 |
16945 CHECK(function->CreationContext() == context); | 16970 CHECK(function->CreationContext() == context); |
16946 CheckContextId(function, 1); | 16971 CheckContextId(function, 1); |
16947 | 16972 |
16948 context.Dispose(); | 16973 context.Dispose(context->GetIsolate()); |
16949 } | 16974 } |
16950 | 16975 |
16951 | 16976 |
16952 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index, | 16977 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index, |
16953 const AccessorInfo& info) { | 16978 const AccessorInfo& info) { |
16954 if (index == 42) return v8_str("yes"); | 16979 if (index == 42) return v8_str("yes"); |
16955 return Handle<v8::Integer>(); | 16980 return Handle<v8::Integer>(); |
16956 } | 16981 } |
16957 | 16982 |
16958 | 16983 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17314 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); | 17339 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); |
17315 CHECK(result4->Equals(Undefined())); | 17340 CHECK(result4->Equals(Undefined())); |
17316 | 17341 |
17317 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); | 17342 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); |
17318 CHECK(result5->Equals( | 17343 CHECK(result5->Equals( |
17319 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); | 17344 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); |
17320 | 17345 |
17321 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | 17346 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); |
17322 CHECK(result6->Equals(Undefined())); | 17347 CHECK(result6->Equals(Undefined())); |
17323 | 17348 |
17324 context.Dispose(); | 17349 context.Dispose(context->GetIsolate()); |
17325 } | 17350 } |
17326 | 17351 |
17327 | 17352 |
17328 THREADED_TEST(Regress125988) { | 17353 THREADED_TEST(Regress125988) { |
17329 v8::HandleScope scope; | 17354 v8::HandleScope scope; |
17330 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); | 17355 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); |
17331 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); | 17356 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); |
17332 LocalContext env; | 17357 LocalContext env; |
17333 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); | 17358 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); |
17334 CompileRun("var a = new Object();" | 17359 CompileRun("var a = new Object();" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17442 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/,func)[1]"))); | 17467 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/,func)[1]"))); |
17443 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[1]"))); | 17468 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[1]"))); |
17444 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); | 17469 CHECK(i->Equals(CompileRun("'abcbd'.replace(/b/g,func)[3]"))); |
17445 | 17470 |
17446 // TODO(1547): Make the following also return "i". | 17471 // TODO(1547): Make the following also return "i". |
17447 // Calling with environment record as base. | 17472 // Calling with environment record as base. |
17448 TestReceiver(o, context->Global(), "func()"); | 17473 TestReceiver(o, context->Global(), "func()"); |
17449 // Calling with no base. | 17474 // Calling with no base. |
17450 TestReceiver(o, context->Global(), "(1,func)()"); | 17475 TestReceiver(o, context->Global(), "(1,func)()"); |
17451 | 17476 |
17452 foreign_context.Dispose(); | 17477 foreign_context.Dispose(foreign_context->GetIsolate()); |
17453 } | 17478 } |
17454 | 17479 |
17455 | 17480 |
17456 uint8_t callback_fired = 0; | 17481 uint8_t callback_fired = 0; |
17457 | 17482 |
17458 | 17483 |
17459 void CallCompletedCallback1() { | 17484 void CallCompletedCallback1() { |
17460 i::OS::Print("Firing callback 1.\n"); | 17485 i::OS::Print("Firing callback 1.\n"); |
17461 callback_fired ^= 1; // Toggle first bit. | 17486 callback_fired ^= 1; // Toggle first bit. |
17462 } | 17487 } |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18155 i::Semaphore* sem_; | 18180 i::Semaphore* sem_; |
18156 volatile int sem_value_; | 18181 volatile int sem_value_; |
18157 }; | 18182 }; |
18158 | 18183 |
18159 | 18184 |
18160 THREADED_TEST(SemaphoreInterruption) { | 18185 THREADED_TEST(SemaphoreInterruption) { |
18161 ThreadInterruptTest().RunTest(); | 18186 ThreadInterruptTest().RunTest(); |
18162 } | 18187 } |
18163 | 18188 |
18164 #endif // WIN32 | 18189 #endif // WIN32 |
OLD | NEW |