| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 const v8::PropertyCallbackInfo<v8::Value>& info) { | 347 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 348 CheckAccessorArgsCorrect(name, info); | 348 CheckAccessorArgsCorrect(name, info); |
| 349 ApiTestFuzzer::Fuzz(); | 349 ApiTestFuzzer::Fuzz(); |
| 350 CheckAccessorArgsCorrect(name, info); | 350 CheckAccessorArgsCorrect(name, info); |
| 351 info.GetReturnValue().Set(v8::Handle<v8::Value>()); | 351 info.GetReturnValue().Set(v8::Handle<v8::Value>()); |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 THREADED_TEST(EmptyResult) { | 355 THREADED_TEST(EmptyResult) { |
| 356 LocalContext context; | 356 LocalContext context; |
| 357 v8::HandleScope scope(context->GetIsolate()); | 357 v8::Isolate* isolate = context->GetIsolate(); |
| 358 v8::HandleScope scope(isolate); |
| 358 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 359 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 359 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); | 360 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); |
| 360 v8::Handle<v8::Object> inst = obj->NewInstance(); | 361 v8::Handle<v8::Object> inst = obj->NewInstance(); |
| 361 context->Global()->Set(v8::String::New("obj"), inst); | 362 context->Global()->Set(v8::String::New("obj"), inst); |
| 362 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); | 363 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); |
| 363 for (int i = 0; i < 10; i++) { | 364 for (int i = 0; i < 10; i++) { |
| 364 Local<Value> result = scr->Run(); | 365 Local<Value> result = scr->Run(); |
| 365 CHECK(result == v8::Undefined()); | 366 CHECK(result == v8::Undefined(isolate)); |
| 366 } | 367 } |
| 367 } | 368 } |
| 368 | 369 |
| 369 | 370 |
| 370 THREADED_TEST(NoReuseRegress) { | 371 THREADED_TEST(NoReuseRegress) { |
| 371 // Check that the IC generated for the one test doesn't get reused | 372 // Check that the IC generated for the one test doesn't get reused |
| 372 // for the other. | 373 // for the other. |
| 373 v8::HandleScope scope(CcTest::isolate()); | 374 v8::Isolate* isolate = CcTest::isolate(); |
| 375 v8::HandleScope scope(isolate); |
| 374 { | 376 { |
| 375 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 377 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 376 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); | 378 obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data")); |
| 377 LocalContext context; | 379 LocalContext context; |
| 378 v8::Handle<v8::Object> inst = obj->NewInstance(); | 380 v8::Handle<v8::Object> inst = obj->NewInstance(); |
| 379 context->Global()->Set(v8::String::New("obj"), inst); | 381 context->Global()->Set(v8::String::New("obj"), inst); |
| 380 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); | 382 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); |
| 381 for (int i = 0; i < 2; i++) { | 383 for (int i = 0; i < 2; i++) { |
| 382 Local<Value> result = scr->Run(); | 384 Local<Value> result = scr->Run(); |
| 383 CHECK(result == v8::Undefined()); | 385 CHECK(result == v8::Undefined(isolate)); |
| 384 } | 386 } |
| 385 } | 387 } |
| 386 { | 388 { |
| 387 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 389 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 388 obj->SetAccessor(v8_str("xxx"), | 390 obj->SetAccessor(v8_str("xxx"), |
| 389 CheckAccessorArgsCorrect, | 391 CheckAccessorArgsCorrect, |
| 390 NULL, | 392 NULL, |
| 391 v8::String::New("data")); | 393 v8::String::New("data")); |
| 392 LocalContext context; | 394 LocalContext context; |
| 393 v8::Handle<v8::Object> inst = obj->NewInstance(); | 395 v8::Handle<v8::Object> inst = obj->NewInstance(); |
| 394 context->Global()->Set(v8::String::New("obj"), inst); | 396 context->Global()->Set(v8::String::New("obj"), inst); |
| 395 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); | 397 Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx")); |
| 396 for (int i = 0; i < 10; i++) { | 398 for (int i = 0; i < 10; i++) { |
| 397 Local<Value> result = scr->Run(); | 399 Local<Value> result = scr->Run(); |
| 398 CHECK(!result.IsEmpty()); | 400 CHECK(!result.IsEmpty()); |
| 399 CHECK_EQ(17, result->Int32Value()); | 401 CHECK_EQ(17, result->Int32Value()); |
| 400 } | 402 } |
| 401 } | 403 } |
| 402 } | 404 } |
| 403 | 405 |
| 404 static void ThrowingGetAccessor( | 406 static void ThrowingGetAccessor( |
| 405 Local<String> name, | 407 Local<String> name, |
| 406 const v8::PropertyCallbackInfo<v8::Value>& info) { | 408 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 407 ApiTestFuzzer::Fuzz(); | 409 ApiTestFuzzer::Fuzz(); |
| 408 v8::ThrowException(v8_str("g")); | 410 info.GetIsolate()->ThrowException(v8_str("g")); |
| 409 } | 411 } |
| 410 | 412 |
| 411 | 413 |
| 412 static void ThrowingSetAccessor(Local<String> name, | 414 static void ThrowingSetAccessor(Local<String> name, |
| 413 Local<Value> value, | 415 Local<Value> value, |
| 414 const v8::PropertyCallbackInfo<void>& info) { | 416 const v8::PropertyCallbackInfo<void>& info) { |
| 415 v8::ThrowException(value); | 417 info.GetIsolate()->ThrowException(value); |
| 416 } | 418 } |
| 417 | 419 |
| 418 | 420 |
| 419 THREADED_TEST(Regress1054726) { | 421 THREADED_TEST(Regress1054726) { |
| 420 LocalContext env; | 422 LocalContext env; |
| 421 v8::HandleScope scope(env->GetIsolate()); | 423 v8::HandleScope scope(env->GetIsolate()); |
| 422 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 424 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 423 obj->SetAccessor(v8_str("x"), | 425 obj->SetAccessor(v8_str("x"), |
| 424 ThrowingGetAccessor, | 426 ThrowingGetAccessor, |
| 425 ThrowingSetAccessor, | 427 ThrowingSetAccessor, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 "}" | 500 "}" |
| 499 "for (var i = 0; i < 100; i++) {" | 501 "for (var i = 0; i < 100; i++) {" |
| 500 " foo();" | 502 " foo();" |
| 501 "}"))->Run(); | 503 "}"))->Run(); |
| 502 } | 504 } |
| 503 | 505 |
| 504 | 506 |
| 505 static void AllocateHandles(Local<String> name, | 507 static void AllocateHandles(Local<String> name, |
| 506 const v8::PropertyCallbackInfo<v8::Value>& info) { | 508 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 507 for (int i = 0; i < i::kHandleBlockSize + 1; i++) { | 509 for (int i = 0; i < i::kHandleBlockSize + 1; i++) { |
| 508 v8::Local<v8::Value>::New(name); | 510 v8::Local<v8::Value>::New(info.GetIsolate(), name); |
| 509 } | 511 } |
| 510 info.GetReturnValue().Set(v8::Integer::New(100)); | 512 info.GetReturnValue().Set(v8::Integer::New(100)); |
| 511 } | 513 } |
| 512 | 514 |
| 513 | 515 |
| 514 THREADED_TEST(HandleScopeSegment) { | 516 THREADED_TEST(HandleScopeSegment) { |
| 515 // Check that we can return values past popping of handle scope | 517 // Check that we can return values past popping of handle scope |
| 516 // segments. | 518 // segments. |
| 517 LocalContext env; | 519 LocalContext env; |
| 518 v8::HandleScope scope(env->GetIsolate()); | 520 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 v8::HandleScope scope(isolate); | 562 v8::HandleScope scope(isolate); |
| 561 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); | 563 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); |
| 562 LocalContext switch_context; | 564 LocalContext switch_context; |
| 563 switch_context->Global()->Set(v8_str("fun"), fun); | 565 switch_context->Global()->Set(v8_str("fun"), fun); |
| 564 v8::TryCatch try_catch; | 566 v8::TryCatch try_catch; |
| 565 CompileRun( | 567 CompileRun( |
| 566 "var o = Object.create(null, { n: { get:fun } });" | 568 "var o = Object.create(null, { n: { get:fun } });" |
| 567 "for (var i = 0; i < 10; i++) o.n;"); | 569 "for (var i = 0; i < 10; i++) o.n;"); |
| 568 CHECK(!try_catch.HasCaught()); | 570 CHECK(!try_catch.HasCaught()); |
| 569 } | 571 } |
| OLD | NEW |