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 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3250 CHECK(global.IsEmpty()); | 3250 CHECK(global.IsEmpty()); |
3251 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); | 3251 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); |
3252 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); | 3252 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); |
3253 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); | 3253 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); |
3254 } | 3254 } |
3255 | 3255 |
3256 | 3256 |
3257 THREADED_TEST(GlobalHandleUpcast) { | 3257 THREADED_TEST(GlobalHandleUpcast) { |
3258 v8::Isolate* isolate = CcTest::isolate(); | 3258 v8::Isolate* isolate = CcTest::isolate(); |
3259 v8::HandleScope scope(isolate); | 3259 v8::HandleScope scope(isolate); |
3260 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); | 3260 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str")); |
3261 v8::Persistent<String> global_string(isolate, local); | 3261 v8::Persistent<String> global_string(isolate, local); |
3262 v8::Persistent<Value>& global_value = | 3262 v8::Persistent<Value>& global_value = |
3263 v8::Persistent<Value>::Cast(global_string); | 3263 v8::Persistent<Value>::Cast(global_string); |
3264 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); | 3264 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); |
3265 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); | 3265 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); |
3266 global_string.Dispose(); | 3266 global_string.Dispose(); |
3267 } | 3267 } |
3268 | 3268 |
3269 | 3269 |
3270 THREADED_TEST(HandleEquality) { | 3270 THREADED_TEST(HandleEquality) { |
(...skipping 29 matching lines...) Expand all Loading... | |
3300 CHECK_EQ(local1 == anotherLocal1, true); | 3300 CHECK_EQ(local1 == anotherLocal1, true); |
3301 CHECK_EQ(local1 != anotherLocal1, false); | 3301 CHECK_EQ(local1 != anotherLocal1, false); |
3302 } | 3302 } |
3303 global1.Dispose(); | 3303 global1.Dispose(); |
3304 global2.Dispose(); | 3304 global2.Dispose(); |
3305 } | 3305 } |
3306 | 3306 |
3307 | 3307 |
3308 THREADED_TEST(LocalHandle) { | 3308 THREADED_TEST(LocalHandle) { |
3309 v8::HandleScope scope(CcTest::isolate()); | 3309 v8::HandleScope scope(CcTest::isolate()); |
3310 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); | 3310 v8::Local<String> local |
3311 CHECK_EQ(local->Length(), 3); | 3311 = v8::Local<String>::New(CcTest::isolate(), v8_str("str")); |
Michael Starzinger
2013/09/26 10:58:31
nit: Move then assignment operator into the line a
| |
3312 | |
3313 local = v8::Local<String>::New(CcTest::isolate(), v8_str("str")); | |
3314 CHECK_EQ(local->Length(), 3); | 3312 CHECK_EQ(local->Length(), 3); |
3315 } | 3313 } |
3316 | 3314 |
3317 | 3315 |
3318 class WeakCallCounter { | 3316 class WeakCallCounter { |
3319 public: | 3317 public: |
3320 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } | 3318 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } |
3321 int id() { return id_; } | 3319 int id() { return id_; } |
3322 void increment() { number_of_weak_calls_++; } | 3320 void increment() { number_of_weak_calls_++; } |
3323 int NumberOfWeakCalls() { return number_of_weak_calls_; } | 3321 int NumberOfWeakCalls() { return number_of_weak_calls_; } |
(...skipping 9178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12502 v8::Isolate::Scope scope(CcTest::isolate()); | 12500 v8::Isolate::Scope scope(CcTest::isolate()); |
12503 if (kLogThreading) | 12501 if (kLogThreading) |
12504 printf("Start test %d\n", test_number_); | 12502 printf("Start test %d\n", test_number_); |
12505 CallTestNumber(test_number_); | 12503 CallTestNumber(test_number_); |
12506 if (kLogThreading) | 12504 if (kLogThreading) |
12507 printf("End test %d\n", test_number_); | 12505 printf("End test %d\n", test_number_); |
12508 } | 12506 } |
12509 | 12507 |
12510 | 12508 |
12511 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { | 12509 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { |
12512 CHECK(v8::Locker::IsLocked(args.GetIsolate())); | 12510 v8::Isolate* isolate = args.GetIsolate(); |
12511 CHECK(v8::Locker::IsLocked(isolate)); | |
12513 ApiTestFuzzer::Fuzz(); | 12512 ApiTestFuzzer::Fuzz(); |
12514 v8::Unlocker unlocker(args.GetIsolate()); | 12513 v8::Unlocker unlocker(isolate); |
12515 const char* code = "throw 7;"; | 12514 const char* code = "throw 7;"; |
12516 { | 12515 { |
12517 v8::Locker nested_locker(args.GetIsolate()); | 12516 v8::Locker nested_locker(isolate); |
12518 v8::HandleScope scope(args.GetIsolate()); | 12517 v8::HandleScope scope(isolate); |
12519 v8::Handle<Value> exception; | 12518 v8::Handle<Value> exception; |
12520 { v8::TryCatch try_catch; | 12519 { v8::TryCatch try_catch; |
12521 v8::Handle<Value> value = CompileRun(code); | 12520 v8::Handle<Value> value = CompileRun(code); |
12522 CHECK(value.IsEmpty()); | 12521 CHECK(value.IsEmpty()); |
12523 CHECK(try_catch.HasCaught()); | 12522 CHECK(try_catch.HasCaught()); |
12524 // Make sure to wrap the exception in a new handle because | 12523 // Make sure to wrap the exception in a new handle because |
12525 // the handle returned from the TryCatch is destroyed | 12524 // the handle returned from the TryCatch is destroyed |
12526 // when the TryCatch is destroyed. | 12525 // when the TryCatch is destroyed. |
12527 exception = Local<Value>::New(try_catch.Exception()); | 12526 exception = Local<Value>::New(isolate, try_catch.Exception()); |
12528 } | 12527 } |
12529 args.GetIsolate()->ThrowException(exception); | 12528 args.GetIsolate()->ThrowException(exception); |
12530 } | 12529 } |
12531 } | 12530 } |
12532 | 12531 |
12533 | 12532 |
12534 static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { | 12533 static void ThrowInJSNoCatch(const v8::FunctionCallbackInfo<v8::Value>& args) { |
12535 CHECK(v8::Locker::IsLocked(CcTest::isolate())); | 12534 CHECK(v8::Locker::IsLocked(CcTest::isolate())); |
12536 ApiTestFuzzer::Fuzz(); | 12535 ApiTestFuzzer::Fuzz(); |
12537 v8::Unlocker unlocker(CcTest::isolate()); | 12536 v8::Unlocker unlocker(CcTest::isolate()); |
(...skipping 8048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20586 Local<Object> data2 = v8::Object::New(); | 20585 Local<Object> data2 = v8::Object::New(); |
20587 function_new_expected_env = data2; | 20586 function_new_expected_env = data2; |
20588 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20587 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
20589 CHECK(!func2->IsNull()); | 20588 CHECK(!func2->IsNull()); |
20590 CHECK_NE(func, func2); | 20589 CHECK_NE(func, func2); |
20591 env->Global()->Set(v8_str("func2"), func2); | 20590 env->Global()->Set(v8_str("func2"), func2); |
20592 Local<Value> result2 = CompileRun("func2();"); | 20591 Local<Value> result2 = CompileRun("func2();"); |
20593 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 20592 CHECK_EQ(v8::Integer::New(17, isolate), result2); |
20594 } | 20593 } |
20595 | 20594 |
OLD | NEW |